mirror of
https://github.com/quantum5/qcal.git
synced 2025-04-25 02:01:56 -04:00
Prevent initial redirect unless the user navigates
This commit is contained in:
parent
2d4125654e
commit
50f8443605
15
src/App.tsx
15
src/App.tsx
|
@ -1,6 +1,16 @@
|
||||||
import React, {FormEvent} from 'react';
|
import React, {FormEvent} from 'react';
|
||||||
import {Calendar} from './Calendar';
|
import {Calendar} from './Calendar';
|
||||||
import {endGregorian, endJD, frSupportedYear, gregorianJDN, jdnFrench, Month, startGregorian, startJD} from './dates';
|
import {
|
||||||
|
dateJDN,
|
||||||
|
endGregorian,
|
||||||
|
endJD,
|
||||||
|
frSupportedYear,
|
||||||
|
gregorianJDN,
|
||||||
|
jdnFrench,
|
||||||
|
Month,
|
||||||
|
startGregorian,
|
||||||
|
startJD
|
||||||
|
} from './dates';
|
||||||
import {TimeOfDay} from './TimeOfDay';
|
import {TimeOfDay} from './TimeOfDay';
|
||||||
|
|
||||||
type YearMonth = {
|
type YearMonth = {
|
||||||
|
@ -33,7 +43,7 @@ class App extends React.Component<{}, AppState> {
|
||||||
constructor(props: {}) {
|
constructor(props: {}) {
|
||||||
super(props);
|
super(props);
|
||||||
const today = new Date();
|
const today = new Date();
|
||||||
const todayJDN = gregorianJDN(today.getFullYear(), today.getMonth() + 1, today.getDate());
|
const todayJDN = dateJDN(today);
|
||||||
const {year, month} = jdnFrench(todayJDN);
|
const {year, month} = jdnFrench(todayJDN);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
|
@ -43,7 +53,6 @@ class App extends React.Component<{}, AppState> {
|
||||||
goMonth: (today.getMonth() + 1).toString(),
|
goMonth: (today.getMonth() + 1).toString(),
|
||||||
goDay: today.getDate().toString(),
|
goDay: today.getDate().toString(),
|
||||||
};
|
};
|
||||||
this.updateURL();
|
|
||||||
this.updateStateFromURL = this.updateStateFromURL.bind(this);
|
this.updateStateFromURL = this.updateStateFromURL.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import './TimeOfDay.scss';
|
import './TimeOfDay.scss';
|
||||||
import {gregorianJDN} from './dates';
|
import {dateJDN, gregorianJDN} from './dates';
|
||||||
|
|
||||||
type TimeStamp = {
|
type TimeStamp = {
|
||||||
hour: number,
|
hour: number,
|
||||||
|
@ -52,7 +52,7 @@ export class TimeOfDay extends React.Component<TimeOfDayProps, TimeOfDayState> {
|
||||||
decimalTimer: 0,
|
decimalTimer: 0,
|
||||||
normal: zero,
|
normal: zero,
|
||||||
normalTimer: 0,
|
normalTimer: 0,
|
||||||
jdn: 0,
|
jdn: dateJDN(new Date()),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,6 +88,10 @@ export function gregorianJDN(year: number, month: number, day: number): number {
|
||||||
return J + dg;
|
return J + dg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function dateJDN(date: Date) {
|
||||||
|
return gregorianJDN(date.getFullYear(), date.getMonth() + 1, date.getDate());
|
||||||
|
}
|
||||||
|
|
||||||
export function frJDN(year: number, month: Month, day: Day): number {
|
export function frJDN(year: number, month: Month, day: Day): number {
|
||||||
const dy = year - startYear;
|
const dy = year - startYear;
|
||||||
const dd = month * 30 + day - 31;
|
const dd = month * 30 + day - 31;
|
||||||
|
|
Loading…
Reference in a new issue