@ende/datetime
ende add jsr:@ende/datetimeVersion 2026.10.15 on JSR.
Utilities for dealing with Date objects.
import { dayOfYear, isLeap, difference, HOUR, MINUTE, SECOND } from "@ende/datetime";
import { assertEquals } from "@ende/assert";
assertEquals(dayOfYear(new Date("2019-03-11T03:24:00")), 70);
assertEquals(isLeap(1970), false);
const date0 = new Date("2018-05-14");
const date1 = new Date("2020-05-13");
assertEquals(difference(date0, date1).years, 1);
assertEquals(HOUR / MINUTE, 60);
assertEquals(MINUTE / SECOND, 60);
Modules
Exports
APRIL— The month index for April.AUGUST— The month index for August.DAY— The number of milliseconds in a day.dayOfYear— Returns the number of the day in the year in the local time zone.dayOfYearUtc— Returns the number of the day in the year in UTC time.DECEMBER— The month index for December.difference— Calculates the difference of the 2 given dates in various units. If the units are omitted, it returns the difference in the all available units.DifferenceFormat— Return type for difference.DifferenceOptions— Options for difference.FEBRUARY— The month index for February.format— Formats a date to a string with the specified format.FormatOptions— Options for format.FRIDAY— The day of week index for Friday.HOUR— The number of milliseconds in an hour.isLeap— Returns whether the given year is a leap year. Passing in a Date object will return the leap year status of the year of that object and take the current timezone into account. Passing in a number will return the leap year status of that number.isUtcLeap— Returns whether the given year is a leap year in UTC time. This always returns the same value regardless of the local timezone.JANUARY— The month index for January.JULY— The month index for July.JUNE— The month index for June.MARCH— The month index for March.MAY— The month index for May.MINUTE— The number of milliseconds in a minute.MONDAY— The day of week index for Monday.NOVEMBER— The month index for November.OCTOBER— The month index for October.parse— Parses a date string using the specified format string.SATURDAY— The day of week index for Saturday.SECOND— The number of milliseconds in a second.SEPTEMBER— The month index for September.SUNDAY— The day of week index for Sunday.THURSDAY— The day of week index for Thursday.TUESDAY— The day of week index for Tuesday.Unit— Duration units for DifferenceFormat and DifferenceOptions.WEDNESDAY— The day of week index for Wednesday.WEEK— The number of milliseconds in a week.weekOfYear— Returns the ISO week number of the provided date (1-53).