@tsdotnet/date-time 1.0.28 → 1.0.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +11 -11
  3. package/dist/CalendarDate.d.ts +12 -0
  4. package/dist/Calendars/Gregorian.d.ts +37 -37
  5. package/dist/ClockTime.d.ts +20 -20
  6. package/dist/ClockTime.js +67 -67
  7. package/dist/ClockTime.js.map +1 -1
  8. package/dist/ClockTimeValue.d.ts +14 -0
  9. package/dist/DateTime.d.ts +154 -154
  10. package/dist/DateTime.js +305 -305
  11. package/dist/DateTime.js.map +1 -1
  12. package/dist/DateTimeKind.d.ts +15 -0
  13. package/dist/JsDateConvertible.d.ts +10 -0
  14. package/dist/TimeMeasurement.d.ts +15 -0
  15. package/dist/TimeQuantity.d.ts +50 -50
  16. package/dist/TimeQuantity.js +95 -95
  17. package/dist/TimeQuantity.js.map +1 -1
  18. package/dist/TimeSpan.d.ts +73 -73
  19. package/dist/TimeSpan.js +111 -111
  20. package/dist/TimeSpan.js.map +1 -1
  21. package/dist/TimeStamp.d.ts +25 -25
  22. package/dist/TimeStamp.js +45 -45
  23. package/dist/TimeStamp.js.map +1 -1
  24. package/dist/TimeStampValue.d.ts +13 -0
  25. package/dist/TimeUnit.d.ts +47 -47
  26. package/dist/TimeUnit.js +99 -99
  27. package/dist/TimeUnit.js.map +1 -1
  28. package/dist/TimeUnitValue.d.ts +19 -19
  29. package/dist/TimeUnitValue.js +46 -46
  30. package/dist/TimeUnitValue.js.map +1 -1
  31. package/dist/date-time.d.ts +20 -20
  32. package/dist/date-time.js +28 -24
  33. package/dist/date-time.js.map +1 -1
  34. package/dist/howMany.d.ts +39 -0
  35. package/dist/howMany.js +53 -0
  36. package/dist/howMany.js.map +1 -0
  37. package/dist-esm/ClockTime.js +62 -62
  38. package/dist-esm/ClockTime.js.map +1 -1
  39. package/dist-esm/DateTime.js +301 -301
  40. package/dist-esm/DateTime.js.map +1 -1
  41. package/dist-esm/TimeQuantity.js +91 -91
  42. package/dist-esm/TimeQuantity.js.map +1 -1
  43. package/dist-esm/TimeSpan.js +106 -106
  44. package/dist-esm/TimeSpan.js.map +1 -1
  45. package/dist-esm/TimeStamp.js +40 -40
  46. package/dist-esm/TimeStamp.js.map +1 -1
  47. package/dist-esm/TimeUnit.js +96 -96
  48. package/dist-esm/TimeUnit.js.map +1 -1
  49. package/dist-esm/TimeUnitValue.js +42 -42
  50. package/dist-esm/date-time.js +15 -13
  51. package/dist-esm/date-time.js.map +1 -1
  52. package/dist-esm/howMany.js +50 -0
  53. package/dist-esm/howMany.js.map +1 -0
  54. package/package.json +81 -62
@@ -1,154 +1,154 @@
1
- /*!
2
- * @author electricessence / https://github.com/electricessence/
3
- * Based on .NET DateTime's interface.
4
- * @license MIT
5
- */
6
- import CalendarDate from './CalendarDate';
7
- import Gregorian from './Calendars/Gregorian';
8
- import ClockTime from './ClockTime';
9
- import DateTimeKind from './DateTimeKind';
10
- import JsDateConvertible from './JsDateConvertible';
11
- import TimeQuantity from './TimeQuantity';
12
- import TimeSpan from './TimeSpan';
13
- import TimeStamp from './TimeStamp';
14
- export default class DateTime implements CalendarDate, JsDateConvertible {
15
- private readonly _value;
16
- private readonly _kind;
17
- private _time;
18
- constructor();
19
- constructor(dateString: string, kind?: DateTimeKind);
20
- constructor(milliseconds: number, kind?: DateTimeKind);
21
- constructor(source: Date, kind?: DateTimeKind);
22
- constructor(source: DateTime, kind?: DateTimeKind);
23
- /**
24
- * Returns the now local time.
25
- * @returns {DateTime}
26
- */
27
- static get now(): DateTime;
28
- /**
29
- * The date component for now.
30
- * @returns {DateTime}
31
- */
32
- static get today(): DateTime;
33
- /**
34
- * Midnight tomorrow.
35
- * @returns {DateTime}
36
- */
37
- static get tomorrow(): DateTime;
38
- get kind(): DateTimeKind;
39
- get year(): number;
40
- /**
41
- * Returns the Gregorian Month (zero indexed).
42
- * @returns {number}
43
- */
44
- get month(): Gregorian.Month;
45
- /**
46
- * Returns the month number (1-12).
47
- * @returns {number}
48
- */
49
- get calendarMonth(): number;
50
- get calendar(): CalendarDate;
51
- /**
52
- * Returns the day of the month. An integer between 1 and 31.
53
- * @returns {number}
54
- */
55
- get day(): number;
56
- /**
57
- * Returns the day of the month indexed starting at zero.
58
- * @returns {number}
59
- */
60
- get dayIndex(): number;
61
- /**
62
- * Returns the zero indexed day of the week. (Sunday == 0)
63
- * @returns {number}
64
- */
65
- get dayOfWeek(): Gregorian.DayOfWeek;
66
- /**
67
- * Returns a DateTime object for 00:00 of this date.
68
- */
69
- get date(): DateTime;
70
- /**
71
- * Returns the time of day represented by a ClockTime object.
72
- * @returns {ClockTime}
73
- */
74
- get timeOfDay(): ClockTime;
75
- /**
76
- * Measures the difference between two dates as a TimeSpan.
77
- * @param first
78
- * @param last
79
- */
80
- static between(first: Date | DateTime, last: Date | DateTime): TimeSpan;
81
- /**
82
- * Calculates if the given year is a leap year using the formula:
83
- * ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)
84
- * @param year
85
- * @returns {boolean}
86
- */
87
- static isLeapYear(year: number): boolean;
88
- /**
89
- * Returns the number of days for the specific year and month.
90
- * @param year
91
- * @param month
92
- * @returns {any}
93
- */
94
- static daysInMonth(year: number, month: Gregorian.Month): number;
95
- static from(calendarDate: CalendarDate): DateTime;
96
- static from(year: number, month: Gregorian.Month, day: number): DateTime;
97
- static fromCalendarDate(calendarDate: CalendarDate): DateTime;
98
- static fromCalendarDate(year: number, month: number, day: number): DateTime;
99
- toJsDate(): Date;
100
- addMilliseconds(ms: number): DateTime;
101
- addSeconds(seconds: number): DateTime;
102
- addMinutes(minutes: number): DateTime;
103
- addHours(hours: number): DateTime;
104
- addDays(days: number): DateTime;
105
- addMonths(months: number): DateTime;
106
- addYears(years: number): DateTime;
107
- /**
108
- * Receives an TimeQuantity value and adds based on the total milliseconds.
109
- * @param {TimeQuantity} time
110
- * @returns {DateTime}
111
- */
112
- add(time: TimeQuantity): DateTime;
113
- /**
114
- * Receives an TimeQuantity value and subtracts based on the total milliseconds.
115
- * @param {TimeQuantity} time
116
- * @returns {DateTime}
117
- */
118
- subtract(time: TimeQuantity): DateTime;
119
- /**
120
- * Returns a TimeSpan representing the amount of time between two dates.
121
- * @param previous
122
- * @returns {TimeSpan}
123
- */
124
- timePassedSince(previous: Date | DateTime): TimeSpan;
125
- /**
126
- * Returns a readonly object which contains all the date and time components.
127
- */
128
- toTimeStamp(): TimeStamp;
129
- /**
130
- * Returns a UTC version of this date if its kind is local.
131
- * @returns {DateTime}
132
- */
133
- toUniversalTime(): DateTime;
134
- /**
135
- * Compares a JS Date with the current instance. Does not evaluate the kind.
136
- * @param other
137
- * @returns {boolean}
138
- */
139
- equals(other: Date): boolean;
140
- /**
141
- * Compares another JsDateConvertible object and returns true if they or their value are equal.
142
- * @param other The other JsDateConvertible object.
143
- * @param strict When strict is true, the 'kind' also must match.
144
- * @returns {boolean}
145
- */
146
- equals(other: JsDateConvertible, strict?: boolean): boolean;
147
- compareTo(other: Date | JsDateConvertible): number;
148
- /**
149
- * Returns true if the value is the same UTC time.
150
- * @param {Date | JsDateConvertible} other
151
- * @return {boolean}
152
- */
153
- equivalent(other: Date | JsDateConvertible): boolean;
154
- }
1
+ /*!
2
+ * @author electricessence / https://github.com/electricessence/
3
+ * Based on .NET DateTime's interface.
4
+ * @license MIT
5
+ */
6
+ import CalendarDate from './CalendarDate';
7
+ import Gregorian from './Calendars/Gregorian';
8
+ import ClockTime from './ClockTime';
9
+ import DateTimeKind from './DateTimeKind';
10
+ import JsDateConvertible from './JsDateConvertible';
11
+ import TimeQuantity from './TimeQuantity';
12
+ import TimeSpan from './TimeSpan';
13
+ import TimeStamp from './TimeStamp';
14
+ export default class DateTime implements CalendarDate, JsDateConvertible {
15
+ private readonly _value;
16
+ private readonly _kind;
17
+ private _time;
18
+ constructor();
19
+ constructor(dateString: string, kind?: DateTimeKind);
20
+ constructor(milliseconds: number, kind?: DateTimeKind);
21
+ constructor(source: Date, kind?: DateTimeKind);
22
+ constructor(source: DateTime, kind?: DateTimeKind);
23
+ /**
24
+ * Returns the now local time.
25
+ * @returns {DateTime}
26
+ */
27
+ static get now(): DateTime;
28
+ /**
29
+ * The date component for now.
30
+ * @returns {DateTime}
31
+ */
32
+ static get today(): DateTime;
33
+ /**
34
+ * Midnight tomorrow.
35
+ * @returns {DateTime}
36
+ */
37
+ static get tomorrow(): DateTime;
38
+ get kind(): DateTimeKind;
39
+ get year(): number;
40
+ /**
41
+ * Returns the Gregorian Month (zero indexed).
42
+ * @returns {number}
43
+ */
44
+ get month(): Gregorian.Month;
45
+ /**
46
+ * Returns the month number (1-12).
47
+ * @returns {number}
48
+ */
49
+ get calendarMonth(): number;
50
+ get calendar(): CalendarDate;
51
+ /**
52
+ * Returns the day of the month. An integer between 1 and 31.
53
+ * @returns {number}
54
+ */
55
+ get day(): number;
56
+ /**
57
+ * Returns the day of the month indexed starting at zero.
58
+ * @returns {number}
59
+ */
60
+ get dayIndex(): number;
61
+ /**
62
+ * Returns the zero indexed day of the week. (Sunday == 0)
63
+ * @returns {number}
64
+ */
65
+ get dayOfWeek(): Gregorian.DayOfWeek;
66
+ /**
67
+ * Returns a DateTime object for 00:00 of this date.
68
+ */
69
+ get date(): DateTime;
70
+ /**
71
+ * Returns the time of day represented by a ClockTime object.
72
+ * @returns {ClockTime}
73
+ */
74
+ get timeOfDay(): ClockTime;
75
+ /**
76
+ * Measures the difference between two dates as a TimeSpan.
77
+ * @param first
78
+ * @param last
79
+ */
80
+ static between(first: Date | DateTime, last: Date | DateTime): TimeSpan;
81
+ /**
82
+ * Calculates if the given year is a leap year using the formula:
83
+ * ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)
84
+ * @param year
85
+ * @returns {boolean}
86
+ */
87
+ static isLeapYear(year: number): boolean;
88
+ /**
89
+ * Returns the number of days for the specific year and month.
90
+ * @param year
91
+ * @param month
92
+ * @returns {any}
93
+ */
94
+ static daysInMonth(year: number, month: Gregorian.Month): number;
95
+ static from(calendarDate: CalendarDate): DateTime;
96
+ static from(year: number, month: Gregorian.Month, day: number): DateTime;
97
+ static fromCalendarDate(calendarDate: CalendarDate): DateTime;
98
+ static fromCalendarDate(year: number, month: number, day: number): DateTime;
99
+ toJsDate(): Date;
100
+ addMilliseconds(ms: number): DateTime;
101
+ addSeconds(seconds: number): DateTime;
102
+ addMinutes(minutes: number): DateTime;
103
+ addHours(hours: number): DateTime;
104
+ addDays(days: number): DateTime;
105
+ addMonths(months: number): DateTime;
106
+ addYears(years: number): DateTime;
107
+ /**
108
+ * Receives an TimeQuantity value and adds based on the total milliseconds.
109
+ * @param {TimeQuantity} time
110
+ * @returns {DateTime}
111
+ */
112
+ add(time: TimeQuantity): DateTime;
113
+ /**
114
+ * Receives an TimeQuantity value and subtracts based on the total milliseconds.
115
+ * @param {TimeQuantity} time
116
+ * @returns {DateTime}
117
+ */
118
+ subtract(time: TimeQuantity): DateTime;
119
+ /**
120
+ * Returns a TimeSpan representing the amount of time between two dates.
121
+ * @param previous
122
+ * @returns {TimeSpan}
123
+ */
124
+ timePassedSince(previous: Date | DateTime): TimeSpan;
125
+ /**
126
+ * Returns a readonly object which contains all the date and time components.
127
+ */
128
+ toTimeStamp(): TimeStamp;
129
+ /**
130
+ * Returns a UTC version of this date if its kind is local.
131
+ * @returns {DateTime}
132
+ */
133
+ toUniversalTime(): DateTime;
134
+ /**
135
+ * Compares a JS Date with the current instance. Does not evaluate the kind.
136
+ * @param other
137
+ * @returns {boolean}
138
+ */
139
+ equals(other: Date): boolean;
140
+ /**
141
+ * Compares another JsDateConvertible object and returns true if they or their value are equal.
142
+ * @param other The other JsDateConvertible object.
143
+ * @param strict When strict is true, the 'kind' also must match.
144
+ * @returns {boolean}
145
+ */
146
+ equals(other: JsDateConvertible, strict?: boolean): boolean;
147
+ compareTo(other: Date | JsDateConvertible): number;
148
+ /**
149
+ * Returns true if the value is the same UTC time.
150
+ * @param {Date | JsDateConvertible} other
151
+ * @return {boolean}
152
+ */
153
+ equivalent(other: Date | JsDateConvertible): boolean;
154
+ }