UNPKG

2.72 kBTypeScriptView Raw
1import { Time } from './datetime';
2declare type Datelike = Pick<Date, 'getTime'>;
3export declare const datetime: (y: number, m: number, d: number, h?: number, i?: number, s?: number) => Date;
4/**
5 * General date-related utilities.
6 * Also handles several incompatibilities between JavaScript and Python
7 *
8 */
9export declare const MONTH_DAYS: number[];
10/**
11 * Number of milliseconds of one day
12 */
13export declare const ONE_DAY: number;
14/**
15 * @see: <http://docs.python.org/library/datetime.html#datetime.MAXYEAR>
16 */
17export declare const MAXYEAR = 9999;
18/**
19 * Python uses 1-Jan-1 as the base for calculating ordinals but we don't
20 * want to confuse the JS engine with milliseconds > Number.MAX_NUMBER,
21 * therefore we use 1-Jan-1970 instead
22 */
23export declare const ORDINAL_BASE: Date;
24/**
25 * Python: MO-SU: 0 - 6
26 * JS: SU-SAT 0 - 6
27 */
28export declare const PY_WEEKDAYS: number[];
29/**
30 * py_date.timetuple()[7]
31 */
32export declare const getYearDay: (date: Date) => number;
33export declare const isLeapYear: (year: number) => boolean;
34export declare const isDate: (value: unknown) => value is Date;
35export declare const isValidDate: (value: unknown) => value is Date;
36/**
37 * @return {Number} the date's timezone offset in ms
38 */
39export declare const tzOffset: (date: Date) => number;
40/**
41 * @see: <http://www.mcfedries.com/JavaScript/DaysBetween.asp>
42 */
43export declare const daysBetween: (date1: Date, date2: Date) => number;
44/**
45 * @see: <http://docs.python.org/library/datetime.html#datetime.date.toordinal>
46 */
47export declare const toOrdinal: (date: Date) => number;
48/**
49 * @see - <http://docs.python.org/library/datetime.html#datetime.date.fromordinal>
50 */
51export declare const fromOrdinal: (ordinal: number) => Date;
52export declare const getMonthDays: (date: Date) => number;
53/**
54 * @return {Number} python-like weekday
55 */
56export declare const getWeekday: (date: Date) => number;
57/**
58 * @see: <http://docs.python.org/library/calendar.html#calendar.monthrange>
59 */
60export declare const monthRange: (year: number, month: number) => number[];
61/**
62 * @see: <http://docs.python.org/library/datetime.html#datetime.datetime.combine>
63 */
64export declare const combine: (date: Date, time: Date | Time) => Date;
65export declare const clone: (date: Date | Time) => Date;
66export declare const cloneDates: (dates: Date[] | Time[]) => Date[];
67/**
68 * Sorts an array of Date or Time objects
69 */
70export declare const sort: <T extends Datelike>(dates: T[]) => void;
71export declare const timeToUntilString: (time: number, utc?: boolean) => string;
72export declare const untilStringToDate: (until: string) => Date;
73export declare const dateInTimeZone: (date: Date, timeZone: string) => Date;
74export {};
75//# sourceMappingURL=dateutil.d.ts.map
\No newline at end of file