Created
August 27, 2018 11:51
-
-
Save M0nica/dbce3432755f07c113df6f248facd4d5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// @flow | |
import { LocalDate, ChronoUnit } from "js-joda"; | |
export function getToday(): LocalDate { | |
return LocalDate.now(); | |
} | |
export function getNextYear(date: LocalDate): number { | |
return date.year() + 1; | |
} | |
export function getFirstDayNextYear(nextYear: number): LocalDate { | |
return LocalDate.of(nextYear, 1, 1); | |
} | |
export function getDaysUntilNextYear( | |
today: LocalDate, | |
firstDayNextYear: LocalDate | |
): number { | |
return today.until(firstDayNextYear, ChronoUnit.DAYS); | |
} | |
export function checkNYE(getDaysUntilNextYear: number): boolean { | |
return Boolean(getDaysUntilNextYear == 1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment