@naturalcycles/js-lib 14.243.1 → 14.244.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.
@@ -63,7 +63,7 @@ class DateInterval {
63
63
  */
64
64
  cmp(d) {
65
65
  d = DateInterval.parse(d);
66
- return this.start.cmp(d.start) || this.end.cmp(d.end);
66
+ return this.start.compare(d.start) || this.end.compare(d.end);
67
67
  }
68
68
  getDays(incl = '[]') {
69
69
  return localDate_1.localDate.range(this.start, this.end, incl, 1, 'day');
@@ -11,19 +11,16 @@ export type LocalDateFormatter = (ld: LocalDate) => string;
11
11
  * It is timezone-independent.
12
12
  */
13
13
  export declare class LocalDate {
14
- private $year;
15
- private $month;
16
- private $day;
17
- constructor($year: number, $month: number, $day: number);
14
+ year: number;
15
+ month: number;
16
+ day: number;
17
+ constructor(year: number, month: number, day: number);
18
18
  get(unit: LocalDateUnitStrict): number;
19
19
  set(unit: LocalDateUnitStrict, v: number, mutate?: boolean): LocalDate;
20
- year(): number;
21
- year(v: number): LocalDate;
22
- month(): number;
23
- month(v: number): LocalDate;
24
- day(): number;
25
- day(v: number): LocalDate;
26
- dayOfWeek(): ISODayOfWeek;
20
+ setYear(v: number): LocalDate;
21
+ setMonth(v: number): LocalDate;
22
+ setDay(v: number): LocalDate;
23
+ get dayOfWeek(): ISODayOfWeek;
27
24
  isSame(d: LocalDateInput): boolean;
28
25
  isBefore(d: LocalDateInput, inclusive?: boolean): boolean;
29
26
  isSameOrBefore(d: LocalDateInput): boolean;
@@ -67,7 +64,7 @@ export declare class LocalDate {
67
64
  * returns 0 if they are equal
68
65
  * returns -1 if this < d
69
66
  */
70
- cmp(d: LocalDateInput): -1 | 0 | 1;
67
+ compare(d: LocalDateInput): -1 | 0 | 1;
71
68
  /**
72
69
  * Same as Math.abs( diff )
73
70
  */
@@ -94,7 +91,7 @@ export declare class LocalDate {
94
91
  * Returns how many days are in the current month.
95
92
  * E.g 31 for January.
96
93
  */
97
- daysInMonth(): number;
94
+ get daysInMonth(): number;
98
95
  clone(): LocalDate;
99
96
  /**
100
97
  * Converts LocalDate into instance of Date.
@@ -140,19 +137,15 @@ export declare class LocalDate {
140
137
  /**
141
138
  * Returns unix timestamp of 00:00:00 of that date (in UTC, because unix timestamp always reflects UTC).
142
139
  */
143
- unix(): UnixTimestampNumber;
140
+ get unix(): UnixTimestampNumber;
144
141
  /**
145
142
  * Same as .unix(), but in milliseconds.
146
143
  */
147
- unixMillis(): UnixTimestampMillisNumber;
144
+ get unixMillis(): UnixTimestampMillisNumber;
148
145
  toJSON(): IsoDateString;
149
146
  format(fmt: Intl.DateTimeFormat | LocalDateFormatter): string;
150
147
  }
151
148
  declare class LocalDateFactory {
152
- /**
153
- * Create LocalDate from year, month and day components.
154
- */
155
- create(year: number, month: number, day: number): LocalDate;
156
149
  /**
157
150
  * Create LocalDate from LocalDateInput.
158
151
  * Input can already be a LocalDate - it is returned as-is in that case.
@@ -162,20 +155,19 @@ declare class LocalDateFactory {
162
155
  *
163
156
  * Will throw if it fails to parse/construct LocalDate.
164
157
  */
165
- of(d: LocalDateInput): LocalDate;
158
+ from(input: LocalDateInput): LocalDate;
166
159
  /**
167
160
  * Tries to construct LocalDate from LocalDateInput, returns null otherwise.
168
161
  * Does not throw (returns null instead).
169
162
  */
170
- parseOrNull(d: LocalDateInputNullable): LocalDate | null;
163
+ fromOrNull(d: LocalDateInputNullable): LocalDate | null;
164
+ fromString(s: string): LocalDate;
165
+ fromStringOrNull(s: string | undefined | null): LocalDate | null;
171
166
  /**
172
167
  * Parses "compact iso8601 format", e.g `19840621` into LocalDate.
173
168
  * Throws if it fails to do so.
174
169
  */
175
- parseCompact(d: string): LocalDate;
176
- getYearLength(year: number): number;
177
- getMonthLength(year: number, month: number): number;
178
- isLeapYear(year: number): boolean;
170
+ fromCompactString(s: string): LocalDate;
179
171
  /**
180
172
  * Constructs LocalDate from Date.
181
173
  * Takes Date as-is, in its timezone - local or UTC.
@@ -186,10 +178,23 @@ declare class LocalDateFactory {
186
178
  * Takes Date's year/month/day components in UTC, using getUTCFullYear, getUTCMonth, getUTCDate.
187
179
  */
188
180
  fromDateInUTC(d: Date): LocalDate;
181
+ /**
182
+ * Create LocalDate from year, month and day components.
183
+ */
184
+ fromComponents(year: number, month: number, day: number): LocalDate;
185
+ fromDateObject(o: DateObject): LocalDate;
186
+ private assertNotNull;
187
+ getYearLength(year: number): number;
188
+ getMonthLength(year: number, month: number): number;
189
+ isLeapYear(year: number): boolean;
190
+ /**
191
+ * Returns true if input is valid to create LocalDate.
192
+ */
193
+ isValid(input: LocalDateInputNullable): boolean;
189
194
  /**
190
195
  * Returns true if isoString is a valid iso8601 string like `yyyy-mm-dd`.
191
196
  */
192
- isValid(isoString: string | undefined | null): boolean;
197
+ isValidString(isoString: string | undefined | null): boolean;
193
198
  /**
194
199
  * Creates LocalDate that represents `today` (in local timezone).
195
200
  */