Skip to content

Commit

Permalink
Merge pull request #806 from ita-social-projects/chronology-dates-und…
Browse files Browse the repository at this point in the history
…er-1924-fix

Chronology dates before 1 may 1984 fix
  • Loading branch information
MementoMorj authored Sep 24, 2023
2 parents 3ded603 + 1e50a10 commit 13940ad
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,22 +79,26 @@ const NewTimelineModal: React.FC<NewTimelineModalProps> = observer(({ timelineIt
historicalContextStore.fetchHistoricalContextAll();
}, []);

const GetLocalHoursOffset = (date: Date) => -1 * date.getTimezoneOffset() / 60;
const GetLocalMinutesOffset = (date: Date) => -1 * date.getTimezoneOffset();

const GetDateBasedOnFormat = (date: Date) => {
let seconds = 0;
// specific GMT+202 Ukraine timezone before 1/5/1924, where seconds are truncated by browser
if(GetLocalMinutesOffset(date) == 122)
{
seconds = 4;
}
date.setHours(0, GetLocalMinutesOffset(date), seconds, 0);
switch (dateTimePickerType) {
case 'date':
date.setHours(GetLocalHoursOffset(date), 0, 0, 0);
return date.toISOString();
case 'month':
case 'season-year':
date.setDate(1);
date.setHours(GetLocalHoursOffset(date), 0, 0, 0);
return date.toISOString();
case 'year':
date.setMonth(0);
date.setDate(1);
date.setHours(GetLocalHoursOffset(date), 0, 0, 0);
return date.toISOString();
default:
throw new Error('Invalid date.');
Expand Down

0 comments on commit 13940ad

Please sign in to comment.