docs(datetime): trim module documentation (#4971)

This commit is contained in:
Asher Gomez 2024-06-06 07:26:08 +10:00 committed by GitHub
parent dfbb3f6590
commit 9551516c93
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -4,105 +4,16 @@
/**
* Utilities for dealing with {@linkcode Date} objects.
*
* ## Constants
* ```ts
* import { dayOfYear, isLeap, difference } from "@std/datetime";
* import { assertEquals } from "@std/assert/assert-equals";
*
* Constants such as {@linkcode SECOND}, {@linkcode MINUTE} and {@linkcode HOUR}
* can be found in the {@linkcode ./constants.ts | constants} module.
*
* ## Day of year
*
* {@linkcode dayOfYear} returns the number of the day in the year in the local
* timezone. {@linkcode dayOfYearUtc} does the same but in UTC time.
*
* ```ts no-assert
* import { dayOfYear } from "@std/datetime/day-of-year";
*
* dayOfYear(new Date("2019-03-11T03:24:00")); // 70
* ```
*
* ## Difference between dates
*
* {@linkcode difference} calculates the difference of the 2 given dates in
* various units.
*
* ```ts no-assert
* import { difference } from "@std/datetime/difference";
* 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");
*
* difference(date0, date1);
* // {
* // milliseconds: 63072000000,
* // seconds: 63072000,
* // minutes: 1051200,
* // hours: 17520,
* // days: 730,
* // weeks: 104,
* // months: 23,
* // quarters: 7,
* // years: 1
* // }
* ```
*
* ## Formatting date strings
*
* {@linkcode format} formats a date to a string with the specified format.
*
* ```ts no-assert
* import { format } from "@std/datetime/format";
*
* const date = new Date(2019, 0, 20, 16, 34, 23, 123);
*
* format(date, "dd-MM-yyyy"); // "20-01-2019"
*
* format(date, "MM-dd-yyyy HH:mm:ss.SSS"); // "01-20-2019 16:34:23.123"
*
* format(date, "'today:' yyyy-MM-dd"); // "today: 2019-01-20"
* ```
*
* ## Detecting leap years
*
* {@linkcode isLeap} returns whether the given year is a leap year.
* {@linkcode isUtcLeap} does the same but in UTC time.
*
* ```ts no-assert
* import { isLeap } from "@std/datetime/is-leap";
*
* isLeap(new Date("1970-01-02")); // false
*
* isLeap(1970); // false
*
* isLeap(new Date("1972-01-02")); // true
*
* isLeap(1972); // true
* ```
*
* ## Parsing date strings
*
* {@linkcode parse} parses a date string using the specified format string.
*
* ```ts no-assert
* import { parse } from "@std/datetime/parse";
*
* parse("20-01-2019", "dd-MM-yyyy"); // 2019-01-19T13:00:00.000Z
*
* parse("01-20-2019 04:34 PM", "MM-dd-yyyy hh:mm a"); // 2019-01-20T05:34:00.000Z
*
* parse("01-20-2019 16:34:23.123", "MM-dd-yyyy HH:mm:ss.SSS"); // 2019-01-20T05:34:23.123Z
* ```
*
* ## Week of year
*
* {@linkcode weekOfYear} returns the number of the week in the year in the local
* timezone.
*
* ```ts no-assert
* import { weekOfYear } from "@std/datetime/week-of-year";
*
* weekOfYear(new Date("2020-12-28T03:24:00")); // 53
*
* weekOfYear(new Date("2020-07-10T03:24:00")); // 28
* assertEquals(difference(date0, date1).years, 1);
* ```
*
* @module