Skip to content

Instantly share code, notes, and snippets.

@M0nica
Created August 27, 2018 11:51
Show Gist options
  • Save M0nica/dbce3432755f07c113df6f248facd4d5 to your computer and use it in GitHub Desktop.
Save M0nica/dbce3432755f07c113df6f248facd4d5 to your computer and use it in GitHub Desktop.
// @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