mirror of
https://github.com/quantum5/qcal.git
synced 2025-04-25 02:01:56 -04:00
Avoid going out of bounds via navigation
This commit is contained in:
parent
c4b2f56772
commit
2a961f2d44
|
@ -1,6 +1,6 @@
|
||||||
import React, {FormEvent} from 'react';
|
import React, {FormEvent} from 'react';
|
||||||
import {Calendar} from './Calendar';
|
import {Calendar} from './Calendar';
|
||||||
import {endGregorian, frSupportedYear, gregorianJDN, jdnFrench, Month, startGregorian} from './dates';
|
import {endGregorian, endJD, frSupportedYear, gregorianJDN, jdnFrench, Month, startGregorian, startJD} from './dates';
|
||||||
|
|
||||||
type YearMonth = {
|
type YearMonth = {
|
||||||
year: number;
|
year: number;
|
||||||
|
@ -92,7 +92,7 @@ class App extends React.Component<{}, AppState> {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const jdn = gregorianJDN(+this.state.goYear, +this.state.goMonth, +this.state.goDay);
|
const jdn = gregorianJDN(+this.state.goYear, +this.state.goMonth, +this.state.goDay);
|
||||||
const {year, month} = jdnFrench(jdn);
|
const {year, month} = jdnFrench(Math.min(Math.max(startJD, jdn), endJD));
|
||||||
this.setState({year, month});
|
this.setState({year, month});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ export const decadeNames = [
|
||||||
'primidi', 'duodi', 'tridi', 'quartidi', 'quintidi', 'sextidi', 'septidi', 'octidi', 'nonidi', 'décadi',
|
'primidi', 'duodi', 'tridi', 'quartidi', 'quintidi', 'sextidi', 'septidi', 'octidi', 'nonidi', 'décadi',
|
||||||
];
|
];
|
||||||
|
|
||||||
const startJD = data.start_jd;
|
export const startJD = data.start_jd;
|
||||||
export const startYear = data.start_year;
|
export const startYear = data.start_year;
|
||||||
const leaps: Array<number> = [0];
|
const leaps: Array<number> = [0];
|
||||||
|
|
||||||
|
@ -107,8 +107,9 @@ export function jdnGregorian(jdn: number): Date {
|
||||||
return new Date(year, month - 1, day);
|
return new Date(year, month - 1, day);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const endJD = frJDN(endYear, 13, frIsLeap(endYear) ? 6: 5);
|
||||||
export const startGregorian = jdnGregorian(startJD);
|
export const startGregorian = jdnGregorian(startJD);
|
||||||
export const endGregorian = jdnGregorian(frJDN(endYear, 13, frIsLeap(endYear) ? 6: 5));
|
export const endGregorian = jdnGregorian(endJD);
|
||||||
|
|
||||||
export function jdnFrench(jdn: number): FrenchDate {
|
export function jdnFrench(jdn: number): FrenchDate {
|
||||||
let lo = 0;
|
let lo = 0;
|
||||||
|
|
Loading…
Reference in a new issue