File tree Expand file tree Collapse file tree 3 files changed +9
-18
lines changed
Expand file tree Collapse file tree 3 files changed +9
-18
lines changed Original file line number Diff line number Diff line change 11import dayjs from 'dayjs' ;
2- import utc from 'dayjs/plugin/utc.js' ;
32import * as bootstrap from 'bootstrap' ;
43import { daysUntilNextBirthday } from './modules/days.js' ;
54import { ver } from './modules/version.js' ;
65
7- dayjs . extend ( utc ) ;
8-
96// Initialize when DOM is loaded
107document . addEventListener ( 'DOMContentLoaded' , ( ) => {
118 // Bootstrap modals are initialized automatically via data-attributes
@@ -68,8 +65,8 @@ document.addEventListener('DOMContentLoaded', () => {
6865 const dateStart = document . getElementById ( 'dateStart' ) . value ;
6966 const dateEnd = document . getElementById ( 'dateEnd' ) . value ;
7067
71- const startDate = dayjs . utc ( dateStart ) ;
72- const endDate = dayjs . utc ( dateEnd ) ;
68+ const startDate = dayjs ( dateStart ) ;
69+ const endDate = dayjs ( dateEnd ) ;
7370
7471 let c = ver ( startDate , endDate ) ;
7572
Original file line number Diff line number Diff line change 11import dayjs from 'dayjs' ;
2- import utc from 'dayjs/plugin/utc.js' ;
3-
4- dayjs . extend ( utc ) ;
52
63/**
7- * Returns number of days until next birthday from now (UTC )
4+ * Returns number of days until next birthday from now (local timezone )
85 * @param {Date|string|number } birthday
96 * @returns {number }
107 */
@@ -13,17 +10,17 @@ export function daysUntilNextBirthday(birthday) {
1310}
1411
1512/**
16- * Returns number of days until next birthday from a given 'now' date (UTC )
13+ * Returns number of days until next birthday from a given 'now' date (local timezone )
1714 * @param {Date|string|number } birthday
1815 * @param {Date|string|number } nowMoment
1916 * @returns {number }
2017 */
2118export function daysUntilNextBirthdayGivenNow ( birthday , nowMoment ) {
22- const b = dayjs . utc ( birthday ) . startOf ( 'day' ) ;
23- const now = dayjs . utc ( nowMoment ) . startOf ( 'day' ) ;
19+ const b = dayjs ( birthday ) . startOf ( 'day' ) ;
20+ const now = dayjs ( nowMoment ) . startOf ( 'day' ) ;
2421
2522 const thisYear = now . year ( ) ;
26- const birthdayThisYear = dayjs . utc ( `${ thisYear } -${ b . format ( 'MM' ) } -${ b . format ( 'DD' ) } ` ) . startOf ( 'day' ) ;
23+ const birthdayThisYear = dayjs ( `${ thisYear } -${ b . format ( 'MM' ) } -${ b . format ( 'DD' ) } ` ) . startOf ( 'day' ) ;
2724 const birthdayNextYear = birthdayThisYear . add ( 1 , 'year' ) . startOf ( 'day' ) ;
2825
2926 const hadBirthdayThisYear = birthdayThisYear . isBefore ( now ) || birthdayThisYear . isSame ( now ) ;
Original file line number Diff line number Diff line change 11import dayjs from 'dayjs' ;
2- import utc from 'dayjs/plugin/utc.js' ;
3-
4- dayjs . extend ( utc ) ;
52
63export function ver ( startDate , endDate ) {
7- const start = dayjs . utc ( startDate ) ;
8- const end = dayjs . utc ( endDate ) ;
4+ const start = dayjs ( startDate ) ;
5+ const end = dayjs ( endDate ) ;
96
107 const years = end . diff ( start , 'year' ) ;
118 const months = end . diff ( start , 'month' ) % 12 ;
You can’t perform that action at this time.
0 commit comments