@tsdotnet/date-time 1.0.29 → 1.1.0

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 (100) hide show
  1. package/dist/CalendarDate.d.ts +1 -0
  2. package/dist/Calendars/Gregorian.d.ts +30 -37
  3. package/dist/ClockTime.d.ts +20 -20
  4. package/dist/ClockTimeValue.d.ts +1 -0
  5. package/dist/DateTime.d.ts +154 -154
  6. package/dist/DateTimeKind.d.ts +10 -15
  7. package/dist/JsDateConvertible.d.ts +1 -0
  8. package/dist/TimeMeasurement.d.ts +1 -0
  9. package/dist/TimeQuantity.d.ts +50 -50
  10. package/dist/TimeSpan.d.ts +73 -73
  11. package/dist/TimeStamp.d.ts +25 -25
  12. package/dist/TimeStampValue.d.ts +1 -0
  13. package/dist/TimeUnit.d.ts +47 -47
  14. package/dist/TimeUnitValue.d.ts +19 -19
  15. package/dist/cjs/Calendars/Gregorian.js +7 -0
  16. package/dist/cjs/Calendars/Gregorian.js.map +1 -0
  17. package/dist/{ClockTime.js → cjs/ClockTime.js} +69 -67
  18. package/dist/cjs/ClockTime.js.map +1 -0
  19. package/dist/{DateTime.js → cjs/DateTime.js} +306 -305
  20. package/dist/cjs/DateTime.js.map +1 -0
  21. package/dist/cjs/DateTimeKind.js +7 -0
  22. package/dist/cjs/DateTimeKind.js.map +1 -0
  23. package/dist/{TimeQuantity.js → cjs/TimeQuantity.js} +95 -95
  24. package/dist/cjs/TimeQuantity.js.map +1 -0
  25. package/dist/{TimeSpan.js → cjs/TimeSpan.js} +112 -111
  26. package/dist/cjs/TimeSpan.js.map +1 -0
  27. package/dist/{TimeStamp.js → cjs/TimeStamp.js} +46 -45
  28. package/dist/cjs/TimeStamp.js.map +1 -0
  29. package/dist/{TimeUnit.js → cjs/TimeUnit.js} +100 -99
  30. package/dist/cjs/TimeUnit.js.map +1 -0
  31. package/dist/{TimeUnitValue.js → cjs/TimeUnitValue.js} +46 -46
  32. package/dist/cjs/TimeUnitValue.js.map +1 -0
  33. package/dist/{date-time.js → cjs/date-time.js} +24 -24
  34. package/dist/cjs/date-time.js.map +1 -0
  35. package/dist/cjs/howMany.js +53 -0
  36. package/dist/cjs/howMany.js.map +1 -0
  37. package/dist/date-time.d.ts +21 -20
  38. package/dist/esm/Calendars/Gregorian.js +6 -0
  39. package/dist/esm/Calendars/Gregorian.js.map +1 -0
  40. package/{dist-esm → dist/esm}/ClockTime.js +70 -62
  41. package/dist/esm/ClockTime.js.map +1 -0
  42. package/{dist-esm → dist/esm}/DateTime.js +305 -301
  43. package/dist/esm/DateTime.js.map +1 -0
  44. package/dist/esm/DateTimeKind.js +6 -0
  45. package/dist/esm/DateTimeKind.js.map +1 -0
  46. package/{dist-esm → dist/esm}/TimeQuantity.js +93 -91
  47. package/dist/esm/TimeQuantity.js.map +1 -0
  48. package/{dist-esm → dist/esm}/TimeSpan.js +132 -106
  49. package/dist/esm/TimeSpan.js.map +1 -0
  50. package/{dist-esm → dist/esm}/TimeStamp.js +49 -40
  51. package/dist/esm/TimeStamp.js.map +1 -0
  52. package/{dist-esm → dist/esm}/TimeUnit.js +97 -96
  53. package/dist/esm/TimeUnit.js.map +1 -0
  54. package/{dist-esm → dist/esm}/TimeUnitValue.js +43 -42
  55. package/dist/esm/TimeUnitValue.js.map +1 -0
  56. package/{dist-esm → dist/esm}/date-time.js +13 -13
  57. package/dist/esm/date-time.js.map +1 -0
  58. package/dist/esm/howMany.js +50 -0
  59. package/dist/esm/howMany.js.map +1 -0
  60. package/dist/howMany.d.ts +39 -59
  61. package/dist/umd/Calendars/Gregorian.js +17 -0
  62. package/dist/umd/Calendars/Gregorian.js.map +1 -0
  63. package/dist/umd/ClockTime.js +86 -0
  64. package/dist/umd/ClockTime.js.map +1 -0
  65. package/dist/umd/DateTime.js +320 -0
  66. package/dist/umd/DateTime.js.map +1 -0
  67. package/dist/umd/DateTimeKind.js +17 -0
  68. package/dist/umd/DateTimeKind.js.map +1 -0
  69. package/dist/umd/TimeQuantity.js +108 -0
  70. package/dist/umd/TimeQuantity.js.map +1 -0
  71. package/dist/umd/TimeSpan.js +148 -0
  72. package/dist/umd/TimeSpan.js.map +1 -0
  73. package/dist/umd/TimeStamp.js +65 -0
  74. package/dist/umd/TimeStamp.js.map +1 -0
  75. package/dist/umd/TimeUnit.js +111 -0
  76. package/dist/umd/TimeUnit.js.map +1 -0
  77. package/dist/umd/TimeUnitValue.js +58 -0
  78. package/dist/umd/TimeUnitValue.js.map +1 -0
  79. package/dist/umd/date-time.js +35 -0
  80. package/dist/umd/date-time.js.map +1 -0
  81. package/dist/umd/howMany.js +63 -0
  82. package/dist/umd/howMany.js.map +1 -0
  83. package/eslint.config.mjs +25 -0
  84. package/package.json +97 -62
  85. package/dist/ClockTime.js.map +0 -1
  86. package/dist/DateTime.js.map +0 -1
  87. package/dist/TimeQuantity.js.map +0 -1
  88. package/dist/TimeSpan.js.map +0 -1
  89. package/dist/TimeStamp.js.map +0 -1
  90. package/dist/TimeUnit.js.map +0 -1
  91. package/dist/TimeUnitValue.js.map +0 -1
  92. package/dist/date-time.js.map +0 -1
  93. package/dist-esm/ClockTime.js.map +0 -1
  94. package/dist-esm/DateTime.js.map +0 -1
  95. package/dist-esm/TimeQuantity.js.map +0 -1
  96. package/dist-esm/TimeSpan.js.map +0 -1
  97. package/dist-esm/TimeStamp.js.map +0 -1
  98. package/dist-esm/TimeUnit.js.map +0 -1
  99. package/dist-esm/TimeUnitValue.js.map +0 -1
  100. package/dist-esm/date-time.js.map +0 -1
@@ -9,4 +9,5 @@ export default interface CalendarDate
9
9
  year: number;
10
10
  month: number;
11
11
  day: number;
12
+ // eslint-disable-next-line semi
12
13
  }
@@ -1,37 +1,30 @@
1
- /*!
2
- * @author electricessence / https://github.com/electricessence/
3
- * @license MIT
4
- */
5
-
6
- declare namespace Gregorian
7
- {
8
- export const enum Month
9
- {
10
- January,
11
- February,
12
- March,
13
- April,
14
- May,
15
- June,
16
- July,
17
- August,
18
- September,
19
- October,
20
- November,
21
- December
22
- }
23
-
24
- export const enum DayOfWeek
25
- {
26
- Sunday,
27
- Monday,
28
- Tuesday,
29
- Wednesday,
30
- Thursday,
31
- Friday,
32
- Saturday
33
- }
34
- }
35
-
36
- export default Gregorian;
37
-
1
+ /*!
2
+ * @author electricessence / https://github.com/electricessence/
3
+ * @license MIT
4
+ */
5
+ declare namespace Gregorian {
6
+ const enum Month {
7
+ January = 0,
8
+ February = 1,
9
+ March = 2,
10
+ April = 3,
11
+ May = 4,
12
+ June = 5,
13
+ July = 6,
14
+ August = 7,
15
+ September = 8,
16
+ October = 9,
17
+ November = 10,
18
+ December = 11
19
+ }
20
+ const enum DayOfWeek {
21
+ Sunday = 0,
22
+ Monday = 1,
23
+ Tuesday = 2,
24
+ Wednesday = 3,
25
+ Thursday = 4,
26
+ Friday = 5,
27
+ Saturday = 6
28
+ }
29
+ }
30
+ export default Gregorian;
@@ -1,20 +1,20 @@
1
- /*!
2
- * @author electricessence / https://github.com/electricessence/
3
- * @license MIT
4
- */
5
- import ClockTimeValue from './ClockTimeValue';
6
- import TimeQuantity from './TimeQuantity';
7
- export declare class ClockTime extends TimeQuantity implements Required<ClockTimeValue> {
8
- readonly day: number;
9
- readonly hour: number;
10
- readonly minute: number;
11
- readonly second: number;
12
- readonly millisecond: number;
13
- readonly tick: number;
14
- constructor(milliseconds: number);
15
- constructor(hours: number, minutes: number, seconds?: number, milliseconds?: number);
16
- static from(hours: number, minutes: number, seconds?: number, milliseconds?: number): ClockTime;
17
- static millisecondsFromTime(hours: number, minutes: number, seconds?: number, milliseconds?: number): number;
18
- toString(): string;
19
- }
20
- export default ClockTime;
1
+ /*!
2
+ * @author electricessence / https://github.com/electricessence/
3
+ * @license MIT
4
+ */
5
+ import type ClockTimeValue from './ClockTimeValue';
6
+ import TimeQuantity from './TimeQuantity';
7
+ export declare class ClockTime extends TimeQuantity implements Required<ClockTimeValue> {
8
+ readonly day: number;
9
+ readonly hour: number;
10
+ readonly minute: number;
11
+ readonly second: number;
12
+ readonly millisecond: number;
13
+ readonly tick: number;
14
+ constructor(milliseconds: number);
15
+ constructor(hours: number, minutes: number, seconds?: number, milliseconds?: number);
16
+ static from(hours: number, minutes: number, seconds?: number, milliseconds?: number): ClockTime;
17
+ static millisecondsFromTime(hours: number, minutes: number, seconds?: number, milliseconds?: number): number;
18
+ toString(): string;
19
+ }
20
+ export default ClockTime;
@@ -11,4 +11,5 @@ export default interface ClockTimeValue
11
11
  second?: number;
12
12
  millisecond?: number;
13
13
  tick?: number;
14
+ // eslint-disable-next-line semi
14
15
  }
@@ -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 type 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,15 +1,10 @@
1
- /*!
2
- * @author electricessence / https://github.com/electricessence/
3
- * @license MIT
4
- */
5
-
6
-
7
-
8
- declare const enum DateTimeKind
9
- {
10
- Unspecified,
11
- Local,
12
- Utc,
13
- }
14
-
15
- export default DateTimeKind;
1
+ /*!
2
+ * @author electricessence / https://github.com/electricessence/
3
+ * @license MIT
4
+ */
5
+ declare const enum DateTimeKind {
6
+ Unspecified = 0,
7
+ Local = 1,
8
+ Utc = 2
9
+ }
10
+ export default DateTimeKind;
@@ -7,4 +7,5 @@
7
7
  export default interface JsDateConvertible
8
8
  {
9
9
  toJsDate (): Date;
10
+ // eslint-disable-next-line semi
10
11
  }
@@ -12,4 +12,5 @@ export default interface TimeMeasurement
12
12
  minutes: number;
13
13
  hours: number;
14
14
  days: number;
15
+ // eslint-disable-next-line semi
15
16
  }
@@ -1,50 +1,50 @@
1
- /*!
2
- * @author electricessence / https://github.com/electricessence/
3
- * @license MIT
4
- */
5
- import ResettableLazy from '@tsdotnet/lazy/dist/ResettableLazy';
6
- import TimeMeasurement from './TimeMeasurement';
7
- import TimeUnit from './TimeUnit';
8
- /**
9
- * This class provides a simple means for storing and calculating time quantities.
10
- */
11
- export default class TimeQuantity {
12
- protected _quantity: number;
13
- constructor(_quantity?: number);
14
- /**
15
- * Combine total values by time unit.
16
- * @param {Partial<TimeMeasurement>} values
17
- * @return {number}
18
- */
19
- static getTotalMillisecondsFrom(values: Partial<TimeMeasurement>): number;
20
- /**
21
- * +1, 0, or -1 depending on the time direction.
22
- * @returns {number}
23
- */
24
- get direction(): number;
25
- protected _total: ResettableLazy<Readonly<TimeMeasurement>>;
26
- /**
27
- * Returns an object with all units exposed as totals.
28
- * @returns {TimeMeasurement}
29
- */
30
- get total(): Readonly<TimeMeasurement>;
31
- getTotalMilliseconds(): number;
32
- /**
33
- * Compares this instance against any other time quantity instance and return true if the amount of time is the same.
34
- * @param other
35
- * @returns {boolean}
36
- */
37
- equals(other: TimeQuantity): boolean;
38
- /**
39
- * Compares this instance against any other time quantity instance.
40
- * @param other
41
- * @returns {number}
42
- */
43
- compareTo(other: TimeQuantity): number;
44
- /**
45
- * Returns the total amount of time measured in the requested TimeUnit.
46
- * @param units
47
- * @returns {number}
48
- */
49
- getTotal(units: TimeUnit.UnitType): number;
50
- }
1
+ /*!
2
+ * @author electricessence / https://github.com/electricessence/
3
+ * @license MIT
4
+ */
5
+ import { ResettableLazy } from '@tsdotnet/lazy';
6
+ import type TimeMeasurement from './TimeMeasurement';
7
+ import TimeUnit from './TimeUnit';
8
+ /**
9
+ * This class provides a simple means for storing and calculating time quantities.
10
+ */
11
+ export default class TimeQuantity {
12
+ protected _quantity: number;
13
+ constructor(_quantity?: number);
14
+ /**
15
+ * Combine total values by time unit.
16
+ * @param {Partial<TimeMeasurement>} values
17
+ * @return {number}
18
+ */
19
+ static getTotalMillisecondsFrom(values: Partial<TimeMeasurement>): number;
20
+ /**
21
+ * +1, 0, or -1 depending on the time direction.
22
+ * @returns {number}
23
+ */
24
+ get direction(): number;
25
+ protected _total: ResettableLazy<Readonly<TimeMeasurement>>;
26
+ /**
27
+ * Returns an object with all units exposed as totals.
28
+ * @returns {TimeMeasurement}
29
+ */
30
+ get total(): Readonly<TimeMeasurement>;
31
+ getTotalMilliseconds(): number;
32
+ /**
33
+ * Compares this instance against any other time quantity instance and return true if the amount of time is the same.
34
+ * @param other
35
+ * @returns {boolean}
36
+ */
37
+ equals(other: TimeQuantity): boolean;
38
+ /**
39
+ * Compares this instance against any other time quantity instance.
40
+ * @param other
41
+ * @returns {number}
42
+ */
43
+ compareTo(other: TimeQuantity): number;
44
+ /**
45
+ * Returns the total amount of time measured in the requested TimeUnit.
46
+ * @param units
47
+ * @returns {number}
48
+ */
49
+ getTotal(units: TimeUnit.UnitType): number;
50
+ }