UNPKG

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