@bitbybit-dev/base 1.2.0 → 1.3.0-rc.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 (55) hide show
  1. package/lib/api/GlobalCDNProvider.js +1 -1
  2. package/lib/api/inputs/base-inputs.d.ts +13 -12
  3. package/lib/api/inputs/color-inputs.d.ts +97 -48
  4. package/lib/api/inputs/color-inputs.js +95 -46
  5. package/lib/api/inputs/dates-inputs.d.ts +67 -26
  6. package/lib/api/inputs/dates-inputs.js +57 -16
  7. package/lib/api/inputs/io-inputs.d.ts +13 -15
  8. package/lib/api/inputs/io-inputs.js +7 -8
  9. package/lib/api/inputs/line-inputs.d.ts +88 -33
  10. package/lib/api/inputs/line-inputs.js +61 -11
  11. package/lib/api/inputs/lists-inputs.d.ts +207 -96
  12. package/lib/api/inputs/lists-inputs.js +153 -45
  13. package/lib/api/inputs/logic-inputs.d.ts +52 -22
  14. package/lib/api/inputs/logic-inputs.js +41 -12
  15. package/lib/api/inputs/math-inputs.d.ts +113 -52
  16. package/lib/api/inputs/math-inputs.js +112 -51
  17. package/lib/api/inputs/mesh-inputs.d.ts +30 -11
  18. package/lib/api/inputs/mesh-inputs.js +21 -3
  19. package/lib/api/inputs/point-inputs.d.ts +240 -107
  20. package/lib/api/inputs/point-inputs.js +199 -73
  21. package/lib/api/inputs/polyline-inputs.d.ts +68 -28
  22. package/lib/api/inputs/polyline-inputs.js +48 -13
  23. package/lib/api/inputs/text-inputs.d.ts +117 -46
  24. package/lib/api/inputs/text-inputs.js +111 -41
  25. package/lib/api/inputs/transforms-inputs.d.ts +65 -23
  26. package/lib/api/inputs/transforms-inputs.js +64 -22
  27. package/lib/api/inputs/vector-inputs.d.ts +154 -76
  28. package/lib/api/inputs/vector-inputs.js +132 -57
  29. package/lib/api/models/point/hex-grid-data.d.ts +1 -1
  30. package/lib/api/models/point/hex-grid-data.js +1 -1
  31. package/lib/api/services/color.d.ts +149 -70
  32. package/lib/api/services/color.js +149 -70
  33. package/lib/api/services/dates.d.ts +313 -150
  34. package/lib/api/services/dates.js +313 -150
  35. package/lib/api/services/line.d.ts +138 -68
  36. package/lib/api/services/line.js +138 -68
  37. package/lib/api/services/lists.d.ts +357 -177
  38. package/lib/api/services/lists.js +357 -177
  39. package/lib/api/services/logic.d.ts +98 -45
  40. package/lib/api/services/logic.js +98 -45
  41. package/lib/api/services/math.d.ts +363 -211
  42. package/lib/api/services/math.js +363 -211
  43. package/lib/api/services/mesh.d.ts +73 -31
  44. package/lib/api/services/mesh.js +73 -31
  45. package/lib/api/services/point.d.ts +367 -147
  46. package/lib/api/services/point.js +367 -147
  47. package/lib/api/services/polyline.d.ts +146 -71
  48. package/lib/api/services/polyline.js +146 -71
  49. package/lib/api/services/text.d.ts +320 -165
  50. package/lib/api/services/text.js +320 -165
  51. package/lib/api/services/transforms.d.ts +145 -58
  52. package/lib/api/services/transforms.js +145 -58
  53. package/lib/api/services/vector.d.ts +381 -156
  54. package/lib/api/services/vector.js +381 -156
  55. package/package.json +1 -1
@@ -1,12 +1,16 @@
1
1
  /**
2
- * Contains various date methods.
2
+ * Dates and times as JavaScript `Date` values: creating them, reading and setting their parts, and
3
+ * formatting them as text. Months count from 0 (January is 0, December 11) and weekdays from 0
4
+ * (Sunday); days of the month count from 1. Every setter returns a new date and leaves the given
5
+ * one unchanged. Local-time and UTC variants exist for most operations.
3
6
  */
4
7
  export class Dates {
5
8
  /**
6
- * Converts date to human-readable date string (excludes time).
7
- * Example: Date(2024,0,15,14,30) → 'Mon Jan 15 2024'
8
- * @param inputs a date
9
- * @returns date as string
9
+ * Formats the date part as text, without the time, in the local time zone.
10
+ *
11
+ * Example: 15 January 2024 at 14:30 -> 'Mon Jan 15 2024'
12
+ * @param inputs - The date
13
+ * @returns The date as text such as 'Mon Jan 15 2024'
10
14
  * @group convert
11
15
  * @shortname date to string
12
16
  * @drawable false
@@ -15,10 +19,11 @@ export class Dates {
15
19
  return inputs.date.toDateString();
16
20
  }
17
21
  /**
18
- * Converts date to ISO 8601 format string (standard format for APIs and data interchange).
19
- * Example: Date(2024,0,15,14,30,45) → '2024-01-15T14:30:45.000Z'
20
- * @param inputs a date
21
- * @returns date as string
22
+ * Formats the date and time in the ISO 8601 form used for data exchange, always in UTC.
23
+ *
24
+ * Example: 15 January 2024 at 14:30 -> '2024-01-15T14:30:45.000Z'
25
+ * @param inputs - The date
26
+ * @returns The date as text such as '2024-01-15T14:30:45.000Z'
22
27
  * @group convert
23
28
  * @shortname date to iso string
24
29
  * @drawable false
@@ -27,10 +32,11 @@ export class Dates {
27
32
  return inputs.date.toISOString();
28
33
  }
29
34
  /**
30
- * Converts date to JSON-compatible string (same as ISO format, used in JSON.stringify).
31
- * Example: Date(2024,0,15,14,30) → '2024-01-15T14:30:00.000Z'
32
- * @param inputs a date
33
- * @returns date as string
35
+ * Formats the date the way it appears inside JSON, which is the ISO 8601 form in UTC.
36
+ *
37
+ * Example: 15 January 2024 at 14:30 -> '2024-01-15T14:30:00.000Z'
38
+ * @param inputs - The date
39
+ * @returns The date as text such as '2024-01-15T14:30:00.000Z'
34
40
  * @group convert
35
41
  * @shortname date to json
36
42
  * @drawable false
@@ -39,10 +45,11 @@ export class Dates {
39
45
  return inputs.date.toJSON();
40
46
  }
41
47
  /**
42
- * Converts date to full locale-specific string (includes date, time, and timezone).
43
- * Example: Date(2024,0,15,14,30) → 'Mon Jan 15 2024 14:30:00 GMT+0000'
44
- * @param inputs a date
45
- * @returns date as string
48
+ * Formats the full date and time as text in the local time zone, with the zone offset.
49
+ *
50
+ * Example: 15 January 2024 at 14:30 -> 'Mon Jan 15 2024 14:30:00 GMT+0000'
51
+ * @param inputs - The date
52
+ * @returns The date and time as text
46
53
  * @group convert
47
54
  * @shortname date to locale string
48
55
  * @drawable false
@@ -51,10 +58,11 @@ export class Dates {
51
58
  return inputs.date.toString();
52
59
  }
53
60
  /**
54
- * Converts date to time string (excludes date, includes timezone).
55
- * Example: Date(2024,0,15,14,30,45) → '14:30:45 GMT+0000'
56
- * @param inputs a date
57
- * @returns time as string
61
+ * Formats the time part as text, without the date, in the local time zone with the zone offset.
62
+ *
63
+ * Example: 15 January 2024 at 14:30 -> '14:30:45 GMT+0000'
64
+ * @param inputs - The date
65
+ * @returns The time as text such as '14:30:45 GMT+0000'
58
66
  * @group convert
59
67
  * @shortname date to time string
60
68
  * @drawable false
@@ -63,10 +71,11 @@ export class Dates {
63
71
  return inputs.date.toTimeString();
64
72
  }
65
73
  /**
66
- * Converts date to UTC string format (Universal Coordinated Time, no timezone offset).
67
- * Example: Date(2024,0,15,14,30) → 'Mon, 15 Jan 2024 14:30:00 GMT'
68
- * @param inputs a date
69
- * @returns date as utc string
74
+ * Formats the date and time as text in UTC.
75
+ *
76
+ * Example: 15 January 2024 at 14:30 -> 'Mon, 15 Jan 2024 14:30:00 GMT'
77
+ * @param inputs - The date
78
+ * @returns The date and time as UTC text
70
79
  * @group convert
71
80
  * @shortname date to utc string
72
81
  * @drawable false
@@ -75,9 +84,8 @@ export class Dates {
75
84
  return inputs.date.toUTCString();
76
85
  }
77
86
  /**
78
- * Returns the current date and time at the moment of execution.
79
- * Example: calling now() → Date object representing current moment (e.g., '2024-01-15T14:30:45')
80
- * @returns date
87
+ * Gives the current date and time at the moment of the call.
88
+ * @returns The current date and time
81
89
  * @group create
82
90
  * @shortname now
83
91
  * @drawable false
@@ -86,59 +94,87 @@ export class Dates {
86
94
  return new Date(Date.now());
87
95
  }
88
96
  /**
89
- * Creates a new date from individual components using local time.
90
- * Month is 0-indexed: 0=January, 11=December.
91
- * Example: year=2024, month=0, day=15, hours=14, minutes=30 → Date(Jan 15, 2024 14:30)
92
- * @param inputs a date
93
- * @returns date
97
+ * Builds a date from its parts, read in the local time zone.
98
+ *
99
+ * The month counts from 0: 0 is January, 11 December. A part outside its range rolls over, so
100
+ * day 32 of January becomes the first of February.
101
+ * Example: year 2024, month 0, day 15, hours 14, minutes 30 -> 15 January 2024 at 14:30 local
102
+ * time
103
+ * @param inputs - The year, month, day, hours, minutes, seconds and milliseconds
104
+ * @returns The date
94
105
  * @group create
95
106
  * @shortname create date
96
107
  * @drawable false
108
+ * @example
109
+ * ```typescript
110
+ * const date = bitbybit.dates.createDate({ year: 2024, month: 0, day: 15, hours: 14, minutes: 30, seconds: 0, milliseconds: 0 });
111
+ * ```
97
112
  */
98
113
  createDate(inputs) {
99
114
  return new Date(inputs.year, inputs.month, inputs.day, inputs.hours, inputs.minutes, inputs.seconds, inputs.milliseconds);
100
115
  }
101
116
  /**
102
- * Creates a new date from individual components using UTC (ignores timezone).
103
- * Returns milliseconds since Unix epoch (Jan 1, 1970 00:00:00 UTC).
104
- * Example: year=2024, month=0, day=15 → Date representing Jan 15, 2024 00:00 UTC
105
- * @param inputs a date
106
- * @returns date
117
+ * Builds a date from its parts, read as UTC so the local time zone plays no part.
118
+ *
119
+ * The month counts from 0: 0 is January, 11 December. A part outside its range rolls over.
120
+ * Example: year 2024, month 0, day 15 -> 15 January 2024 at 00:00 UTC
121
+ * @param inputs - The year, month, day, hours, minutes, seconds and milliseconds
122
+ * @returns The date
107
123
  * @group create
108
124
  * @shortname create utc date
109
125
  * @drawable false
126
+ * @example
127
+ * ```typescript
128
+ * const date = bitbybit.dates.createDateUTC({ year: 2024, month: 0, day: 15, hours: 0, minutes: 0, seconds: 0, milliseconds: 0 });
129
+ * ```
110
130
  */
111
131
  createDateUTC(inputs) {
112
132
  return new Date(Date.UTC(inputs.year, inputs.month, inputs.day, inputs.hours, inputs.minutes, inputs.seconds, inputs.milliseconds));
113
133
  }
114
134
  /**
115
- * Creates a date from Unix timestamp (milliseconds since Jan 1, 1970 UTC).
116
- * Example: unixTimeStamp=1705329000000 → Date(Jan 15, 2024 14:30:00)
117
- * @param inputs a unix time stamp
118
- * @returns date
135
+ * Builds a date from a Unix timestamp: the number of milliseconds since 1 January 1970 at 00:00
136
+ * UTC.
137
+ *
138
+ * Example: 1705329000000 -> 15 January 2024 at 14:30 UTC
139
+ * @param inputs - The timestamp in milliseconds
140
+ * @returns The date
119
141
  * @group create
120
142
  * @shortname create from unix timestamp
121
143
  * @drawable false
144
+ * @example
145
+ * ```typescript
146
+ * const date = bitbybit.dates.createFromUnixTimeStamp({ unixTimeStamp: 1705329000000 });
147
+ * ```
122
148
  */
123
149
  createFromUnixTimeStamp(inputs) {
124
150
  return new Date(inputs.unixTimeStamp);
125
151
  }
126
152
  /**
127
- * Parses a date string and returns Unix timestamp (milliseconds since Jan 1, 1970 UTC).
128
- * Example: dateString='2024-01-15' → 1705276800000
129
- * @param inputs a date string
130
- * @returns the number of milliseconds between that date and midnight, January 1, 1970.
153
+ * Reads a date written as text and gives its Unix timestamp, the milliseconds since 1 January
154
+ * 1970 at 00:00 UTC.
155
+ *
156
+ * ISO 8601 text such as '2024-01-15' or '2024-01-15T14:30:00Z' is read reliably; text that
157
+ * cannot be read gives NaN.
158
+ * Example: '2024-01-15' -> 1705276800000
159
+ * @param inputs - The date as text
160
+ * @returns The timestamp in milliseconds, or NaN when the text is not a date
131
161
  * @group parse
132
162
  * @shortname parse date string
133
163
  * @drawable false
164
+ * @example
165
+ * ```typescript
166
+ * const stamp = bitbybit.dates.parseDate({ dateString: "2024-01-15T14:30:00Z" });
167
+ * ```
134
168
  */
135
169
  parseDate(inputs) {
136
170
  return Date.parse(inputs.dateString);
137
171
  }
138
172
  /**
139
- * Extracts day of the month from date (1-31) using local time.
140
- * Example: Date(2024,0,15) → 15
141
- * @returns date
173
+ * Reads the day of the month, from 1 to 31, in the local time zone.
174
+ *
175
+ * Example: 15 January 2024 -> 15
176
+ * @param inputs - The date
177
+ * @returns The day of the month
142
178
  * @group get
143
179
  * @shortname get date of month
144
180
  * @drawable false
@@ -147,9 +183,11 @@ export class Dates {
147
183
  return inputs.date.getDate();
148
184
  }
149
185
  /**
150
- * Extracts day of the week from date (0=Sunday, 6=Saturday) using local time.
151
- * Example: Date(2024,0,15) → 1 (Monday)
152
- * @returns day
186
+ * Reads the day of the week in the local time zone: 0 is Sunday, 6 Saturday.
187
+ *
188
+ * Example: 15 January 2024 -> 1, a Monday
189
+ * @param inputs - The date
190
+ * @returns The weekday from 0 to 6
153
191
  * @group get
154
192
  * @shortname get weekday
155
193
  * @drawable false
@@ -158,9 +196,11 @@ export class Dates {
158
196
  return inputs.date.getDay();
159
197
  }
160
198
  /**
161
- * Extracts full year from date using local time.
162
- * Example: Date(2024,0,15) → 2024
163
- * @returns year
199
+ * Reads the full year in the local time zone.
200
+ *
201
+ * Example: 15 January 2024 -> 2024
202
+ * @param inputs - The date
203
+ * @returns The year
164
204
  * @group get
165
205
  * @shortname get year
166
206
  * @drawable false
@@ -169,9 +209,11 @@ export class Dates {
169
209
  return inputs.date.getFullYear();
170
210
  }
171
211
  /**
172
- * Extracts month from date (0=January, 11=December) using local time.
173
- * Example: Date(2024,0,15) → 0 (January)
174
- * @returns month
212
+ * Reads the month in the local time zone, counting from 0: 0 is January, 11 December.
213
+ *
214
+ * Example: 15 January 2024 -> 0
215
+ * @param inputs - The date
216
+ * @returns The month from 0 to 11
175
217
  * @group get
176
218
  * @shortname get month
177
219
  * @drawable false
@@ -180,9 +222,11 @@ export class Dates {
180
222
  return inputs.date.getMonth();
181
223
  }
182
224
  /**
183
- * Extracts hours from date (0-23) using local time.
184
- * Example: Date(2024,0,15,14,30) → 14
185
- * @returns hours
225
+ * Reads the hour, from 0 to 23, in the local time zone.
226
+ *
227
+ * Example: 14:30 -> 14
228
+ * @param inputs - The date
229
+ * @returns The hour
186
230
  * @group get
187
231
  * @shortname get hours
188
232
  * @drawable false
@@ -191,9 +235,11 @@ export class Dates {
191
235
  return inputs.date.getHours();
192
236
  }
193
237
  /**
194
- * Extracts minutes from date (0-59) using local time.
195
- * Example: Date(2024,0,15,14,30) → 30
196
- * @returns minutes
238
+ * Reads the minutes, from 0 to 59, in the local time zone.
239
+ *
240
+ * Example: 14:30 -> 30
241
+ * @param inputs - The date
242
+ * @returns The minutes
197
243
  * @group get
198
244
  * @shortname get minutes
199
245
  * @drawable false
@@ -202,9 +248,11 @@ export class Dates {
202
248
  return inputs.date.getMinutes();
203
249
  }
204
250
  /**
205
- * Extracts seconds from date (0-59) using local time.
206
- * Example: Date(2024,0,15,14,30,45) → 45
207
- * @returns seconds
251
+ * Reads the seconds, from 0 to 59, in the local time zone.
252
+ *
253
+ * Example: 14:30:45 -> 45
254
+ * @param inputs - The date
255
+ * @returns The seconds
208
256
  * @group get
209
257
  * @shortname get seconds
210
258
  * @drawable false
@@ -213,9 +261,11 @@ export class Dates {
213
261
  return inputs.date.getSeconds();
214
262
  }
215
263
  /**
216
- * Extracts milliseconds from date (0-999) using local time.
217
- * Example: Date(2024,0,15,14,30,45,123) → 123
218
- * @returns milliseconds
264
+ * Reads the milliseconds, from 0 to 999, in the local time zone.
265
+ *
266
+ * Example: 14:30:45.123 -> 123
267
+ * @param inputs - The date
268
+ * @returns The milliseconds
219
269
  * @group get
220
270
  * @shortname get milliseconds
221
271
  * @drawable false
@@ -224,9 +274,11 @@ export class Dates {
224
274
  return inputs.date.getMilliseconds();
225
275
  }
226
276
  /**
227
- * Converts date to Unix timestamp (milliseconds since Jan 1, 1970 UTC).
228
- * Example: Date(2024,0,15,14,30) → 1705329000000
229
- * @returns time
277
+ * Gives the date as a Unix timestamp: the milliseconds since 1 January 1970 at 00:00 UTC.
278
+ *
279
+ * Example: 15 January 2024 at 14:30 UTC -> 1705329000000
280
+ * @param inputs - The date
281
+ * @returns The timestamp in milliseconds
230
282
  * @group get
231
283
  * @shortname get time
232
284
  * @drawable false
@@ -235,9 +287,11 @@ export class Dates {
235
287
  return inputs.date.getTime();
236
288
  }
237
289
  /**
238
- * Extracts full year from date using UTC (ignores timezone).
239
- * Example: Date(2024,0,15) → 2024
240
- * @returns year
290
+ * Reads the full year in UTC.
291
+ *
292
+ * Example: 15 January 2024 -> 2024
293
+ * @param inputs - The date
294
+ * @returns The year
241
295
  * @group get
242
296
  * @shortname get utc year
243
297
  * @drawable false
@@ -246,9 +300,11 @@ export class Dates {
246
300
  return inputs.date.getUTCFullYear();
247
301
  }
248
302
  /**
249
- * Extracts month from date (0=January, 11=December) using UTC.
250
- * Example: Date.UTC(2024,0,15) → 0 (January)
251
- * @returns month
303
+ * Reads the month in UTC, counting from 0: 0 is January, 11 December.
304
+ *
305
+ * Example: 15 January 2024 -> 0
306
+ * @param inputs - The date
307
+ * @returns The month from 0 to 11
252
308
  * @group get
253
309
  * @shortname get utc month
254
310
  * @drawable false
@@ -257,9 +313,11 @@ export class Dates {
257
313
  return inputs.date.getUTCMonth();
258
314
  }
259
315
  /**
260
- * Extracts day of the month from date (1-31) using UTC.
261
- * Example: Date.UTC(2024,0,15) → 15
262
- * @returns day
316
+ * Reads the day of the month, from 1 to 31, in UTC.
317
+ *
318
+ * Example: 15 January 2024 -> 15
319
+ * @param inputs - The date
320
+ * @returns The day of the month
263
321
  * @group get
264
322
  * @shortname get utc day
265
323
  * @drawable false
@@ -268,9 +326,11 @@ export class Dates {
268
326
  return inputs.date.getUTCDate();
269
327
  }
270
328
  /**
271
- * Extracts hours from date (0-23) using UTC.
272
- * Example: Date.UTC(2024,0,15,14) → 14
273
- * @returns hours
329
+ * Reads the hour, from 0 to 23, in UTC.
330
+ *
331
+ * Example: 14:00 UTC -> 14
332
+ * @param inputs - The date
333
+ * @returns The hour
274
334
  * @group get
275
335
  * @shortname get utc hours
276
336
  * @drawable false
@@ -279,9 +339,11 @@ export class Dates {
279
339
  return inputs.date.getUTCHours();
280
340
  }
281
341
  /**
282
- * Extracts minutes from date (0-59) using UTC.
283
- * Example: Date.UTC(2024,0,15,14,30) → 30
284
- * @returns minutes
342
+ * Reads the minutes, from 0 to 59, in UTC.
343
+ *
344
+ * Example: 14:30 UTC -> 30
345
+ * @param inputs - The date
346
+ * @returns The minutes
285
347
  * @group get
286
348
  * @shortname get utc minutes
287
349
  * @drawable false
@@ -290,9 +352,11 @@ export class Dates {
290
352
  return inputs.date.getUTCMinutes();
291
353
  }
292
354
  /**
293
- * Extracts seconds from date (0-59) using UTC.
294
- * Example: Date.UTC(2024,0,15,14,30,45) → 45
295
- * @returns seconds
355
+ * Reads the seconds, from 0 to 59, in UTC.
356
+ *
357
+ * Example: 14:30:45 UTC -> 45
358
+ * @param inputs - The date
359
+ * @returns The seconds
296
360
  * @group get
297
361
  * @shortname get utc seconds
298
362
  * @drawable false
@@ -301,9 +365,11 @@ export class Dates {
301
365
  return inputs.date.getUTCSeconds();
302
366
  }
303
367
  /**
304
- * Extracts milliseconds from date (0-999) using UTC.
305
- * Example: Date.UTC(2024,0,15,14,30,45,123) → 123
306
- * @returns milliseconds
368
+ * Reads the milliseconds, from 0 to 999, in UTC.
369
+ *
370
+ * Example: 14:30:45.123 UTC -> 123
371
+ * @param inputs - The date
372
+ * @returns The milliseconds
307
373
  * @group get
308
374
  * @shortname get utc milliseconds
309
375
  * @drawable false
@@ -312,41 +378,59 @@ export class Dates {
312
378
  return inputs.date.getUTCMilliseconds();
313
379
  }
314
380
  /**
315
- * Creates new date with modified year (returns new date, original unchanged).
316
- * Example: Date(2024,0,15) with year=2025 → Date(2025,0,15)
317
- * @param inputs a date and the year
318
- * @returns date
381
+ * Makes a copy of the date with another year, in the local time zone. The given date is not
382
+ * changed.
383
+ *
384
+ * Example: 15 January 2024 with year 2025 -> 15 January 2025
385
+ * @param inputs - The date and the year
386
+ * @returns A new date with the year changed
319
387
  * @group set
320
388
  * @shortname set year
321
389
  * @drawable false
322
- * */
390
+ * @example
391
+ * ```typescript
392
+ * const changed = bitbybit.dates.setYear({ date: bitbybit.dates.now(), year: 2025 });
393
+ * ```
394
+ */
323
395
  setYear(inputs) {
324
396
  const dateCopy = new Date(inputs.date.getTime());
325
397
  dateCopy.setFullYear(inputs.year);
326
398
  return dateCopy;
327
399
  }
328
400
  /**
329
- * Creates new date with modified month (0=January, 11=December, returns new date).
330
- * Example: Date(2024,0,15) with month=5 → Date(2024,5,15) (June 15)
331
- * @param inputs a date and the month
332
- * @returns date
401
+ * Makes a copy of the date with another month, in the local time zone; months count from 0. The
402
+ * given date is not changed.
403
+ *
404
+ * Example: 15 January 2024 with month 5 -> 15 June 2024
405
+ * @param inputs - The date and the month from 0 to 11
406
+ * @returns A new date with the month changed
333
407
  * @group set
334
408
  * @shortname set month
335
409
  * @drawable false
336
- * */
410
+ * @example
411
+ * ```typescript
412
+ * const changed = bitbybit.dates.setMonth({ date: bitbybit.dates.now(), month: 5 });
413
+ * ```
414
+ */
337
415
  setMonth(inputs) {
338
416
  const dateCopy = new Date(inputs.date.getTime());
339
417
  dateCopy.setMonth(inputs.month);
340
418
  return dateCopy;
341
419
  }
342
420
  /**
343
- * Creates new date with modified day of month (1-31, returns new date).
344
- * Example: Date(2024,0,15) with day=20 → Date(2024,0,20)
345
- * @param inputs a date and the day
346
- * @returns date
421
+ * Makes a copy of the date with another day of the month, in the local time zone. The given
422
+ * date is not changed.
423
+ *
424
+ * Example: 15 January 2024 with day 20 -> 20 January 2024
425
+ * @param inputs - The date and the day from 1 to 31
426
+ * @returns A new date with the day changed
347
427
  * @group set
348
428
  * @shortname set day of month
349
429
  * @drawable false
430
+ * @example
431
+ * ```typescript
432
+ * const changed = bitbybit.dates.setDayOfMonth({ date: bitbybit.dates.now(), day: 20 });
433
+ * ```
350
434
  */
351
435
  setDayOfMonth(inputs) {
352
436
  const dateCopy = new Date(inputs.date.getTime());
@@ -354,38 +438,59 @@ export class Dates {
354
438
  return dateCopy;
355
439
  }
356
440
  /**
357
- * Sets the hour value in the Date object using local time.
358
- * @param inputs a date and the hours
359
- * @returns date
441
+ * Makes a copy of the date with another hour, in the local time zone. The given date is not
442
+ * changed.
443
+ *
444
+ * Example: 14:30 with hours 9 -> 09:30
445
+ * @param inputs - The date and the hour from 0 to 23
446
+ * @returns A new date with the hour changed
360
447
  * @group set
361
448
  * @shortname set hours
362
449
  * @drawable false
363
- * */
450
+ * @example
451
+ * ```typescript
452
+ * const changed = bitbybit.dates.setHours({ date: bitbybit.dates.now(), hours: 9 });
453
+ * ```
454
+ */
364
455
  setHours(inputs) {
365
456
  const dateCopy = new Date(inputs.date.getTime());
366
457
  dateCopy.setHours(inputs.hours);
367
458
  return dateCopy;
368
459
  }
369
460
  /**
370
- * Sets the minutes value in the Date object using local time.
371
- * @param inputs a date and the minutes
372
- * @returns date
461
+ * Makes a copy of the date with other minutes, in the local time zone. The given date is not
462
+ * changed.
463
+ *
464
+ * Example: 14:30 with minutes 45 -> 14:45
465
+ * @param inputs - The date and the minutes from 0 to 59
466
+ * @returns A new date with the minutes changed
373
467
  * @group set
374
468
  * @shortname set minutes
375
469
  * @drawable false
376
- * */
470
+ * @example
471
+ * ```typescript
472
+ * const changed = bitbybit.dates.setMinutes({ date: bitbybit.dates.now(), minutes: 45 });
473
+ * ```
474
+ */
377
475
  setMinutes(inputs) {
378
476
  const dateCopy = new Date(inputs.date.getTime());
379
477
  dateCopy.setMinutes(inputs.minutes);
380
478
  return dateCopy;
381
479
  }
382
480
  /**
383
- * Sets the seconds value in the Date object using local time.
384
- * @param inputs a date and the seconds
385
- * @returns date
481
+ * Makes a copy of the date with other seconds, in the local time zone. The given date is not
482
+ * changed.
483
+ *
484
+ * Example: 14:30:00 with seconds 30 -> 14:30:30
485
+ * @param inputs - The date and the seconds from 0 to 59
486
+ * @returns A new date with the seconds changed
386
487
  * @group set
387
488
  * @shortname set seconds
388
489
  * @drawable false
490
+ * @example
491
+ * ```typescript
492
+ * const changed = bitbybit.dates.setSeconds({ date: bitbybit.dates.now(), seconds: 30 });
493
+ * ```
389
494
  */
390
495
  setSeconds(inputs) {
391
496
  const dateCopy = new Date(inputs.date.getTime());
@@ -393,12 +498,19 @@ export class Dates {
393
498
  return dateCopy;
394
499
  }
395
500
  /**
396
- * Sets the milliseconds value in the Date object using local time.
397
- * @param inputs a date and the milliseconds
398
- * @returns date
501
+ * Makes a copy of the date with other milliseconds, in the local time zone. The given date is
502
+ * not changed.
503
+ *
504
+ * Example: 14:30:00.000 with milliseconds 500 -> 14:30:00.500
505
+ * @param inputs - The date and the milliseconds from 0 to 999
506
+ * @returns A new date with the milliseconds changed
399
507
  * @group set
400
508
  * @shortname set milliseconds
401
509
  * @drawable false
510
+ * @example
511
+ * ```typescript
512
+ * const changed = bitbybit.dates.setMilliseconds({ date: bitbybit.dates.now(), milliseconds: 500 });
513
+ * ```
402
514
  */
403
515
  setMilliseconds(inputs) {
404
516
  const dateCopy = new Date(inputs.date.getTime());
@@ -406,12 +518,19 @@ export class Dates {
406
518
  return dateCopy;
407
519
  }
408
520
  /**
409
- * Sets the date and time value in the Date object.
410
- * @param inputs a date and the time
411
- * @returns date
521
+ * Makes a copy of the date moved to a Unix timestamp, the milliseconds since 1 January 1970 at
522
+ * 00:00 UTC. The given date is not changed.
523
+ *
524
+ * Example: any date with time 0 -> 1 January 1970 at 00:00 UTC
525
+ * @param inputs - The date and the timestamp in milliseconds
526
+ * @returns A new date with the timestamp changed
412
527
  * @group set
413
528
  * @shortname set time
414
529
  * @drawable false
530
+ * @example
531
+ * ```typescript
532
+ * const changed = bitbybit.dates.setTime({ date: bitbybit.dates.now(), time: 1705329000000 });
533
+ * ```
415
534
  */
416
535
  setTime(inputs) {
417
536
  const dateCopy = new Date(inputs.date.getTime());
@@ -419,38 +538,58 @@ export class Dates {
419
538
  return dateCopy;
420
539
  }
421
540
  /**
422
- * Sets the year value in the Date object using Universal Coordinated Time (UTC).
423
- * @param inputs a date and the year
424
- * @returns date
541
+ * Makes a copy of the date with another year, in UTC. The given date is not changed.
542
+ *
543
+ * Example: 15 January 2024 with year 2025 -> 15 January 2025
544
+ * @param inputs - The date and the year
545
+ * @returns A new date with the year changed
425
546
  * @group set
426
547
  * @shortname set utc year
427
548
  * @drawable false
428
- * */
549
+ * @example
550
+ * ```typescript
551
+ * const changed = bitbybit.dates.setUTCYear({ date: bitbybit.dates.now(), year: 2025 });
552
+ * ```
553
+ */
429
554
  setUTCYear(inputs) {
430
555
  const dateCopy = new Date(inputs.date.getTime());
431
556
  dateCopy.setUTCFullYear(inputs.year);
432
557
  return dateCopy;
433
558
  }
434
559
  /**
435
- * Sets the month value in the Date object using Universal Coordinated Time (UTC).
436
- * @param inputs a date and the month
437
- * @returns date
560
+ * Makes a copy of the date with another month, in UTC; months count from 0. The given date is
561
+ * not changed.
562
+ *
563
+ * Example: 15 January 2024 with month 5 -> 15 June 2024
564
+ * @param inputs - The date and the month from 0 to 11
565
+ * @returns A new date with the month changed
438
566
  * @group set
439
567
  * @shortname set utc month
440
568
  * @drawable false
441
- * */
569
+ * @example
570
+ * ```typescript
571
+ * const changed = bitbybit.dates.setUTCMonth({ date: bitbybit.dates.now(), month: 5 });
572
+ * ```
573
+ */
442
574
  setUTCMonth(inputs) {
443
575
  const dateCopy = new Date(inputs.date.getTime());
444
576
  dateCopy.setUTCMonth(inputs.month);
445
577
  return dateCopy;
446
578
  }
447
579
  /**
448
- * Sets the numeric day of the month in the Date object using Universal Coordinated Time (UTC).
449
- * @param inputs a date and the day
450
- * @returns date
580
+ * Makes a copy of the date with another day of the month, in UTC. The given date is not
581
+ * changed.
582
+ *
583
+ * Example: 15 January 2024 with day 20 -> 20 January 2024
584
+ * @param inputs - The date and the day from 1 to 31
585
+ * @returns A new date with the day changed
451
586
  * @group set
452
587
  * @shortname set utc day
453
588
  * @drawable false
589
+ * @example
590
+ * ```typescript
591
+ * const changed = bitbybit.dates.setUTCDay({ date: bitbybit.dates.now(), day: 20 });
592
+ * ```
454
593
  */
455
594
  setUTCDay(inputs) {
456
595
  const dateCopy = new Date(inputs.date.getTime());
@@ -458,38 +597,56 @@ export class Dates {
458
597
  return dateCopy;
459
598
  }
460
599
  /**
461
- * Sets the hours value in the Date object using Universal Coordinated Time (UTC).
462
- * @param inputs a date and the hours
463
- * @returns date
600
+ * Makes a copy of the date with another hour, in UTC. The given date is not changed.
601
+ *
602
+ * Example: 14:30 UTC with hours 9 -> 09:30 UTC
603
+ * @param inputs - The date and the hour from 0 to 23
604
+ * @returns A new date with the hour changed
464
605
  * @group set
465
606
  * @shortname set utc hours
466
607
  * @drawable false
467
- * */
608
+ * @example
609
+ * ```typescript
610
+ * const changed = bitbybit.dates.setUTCHours({ date: bitbybit.dates.now(), hours: 9 });
611
+ * ```
612
+ */
468
613
  setUTCHours(inputs) {
469
614
  const dateCopy = new Date(inputs.date.getTime());
470
615
  dateCopy.setUTCHours(inputs.hours);
471
616
  return dateCopy;
472
617
  }
473
618
  /**
474
- * Sets the minutes value in the Date object using Universal Coordinated Time (UTC).
475
- * @param inputs a date and the minutes
476
- * @returns date
619
+ * Makes a copy of the date with other minutes, in UTC. The given date is not changed.
620
+ *
621
+ * Example: 14:30 UTC with minutes 45 -> 14:45 UTC
622
+ * @param inputs - The date and the minutes from 0 to 59
623
+ * @returns A new date with the minutes changed
477
624
  * @group set
478
625
  * @shortname set utc minutes
479
626
  * @drawable false
480
- * */
627
+ * @example
628
+ * ```typescript
629
+ * const changed = bitbybit.dates.setUTCMinutes({ date: bitbybit.dates.now(), minutes: 45 });
630
+ * ```
631
+ */
481
632
  setUTCMinutes(inputs) {
482
633
  const dateCopy = new Date(inputs.date.getTime());
483
634
  dateCopy.setUTCMinutes(inputs.minutes);
484
635
  return dateCopy;
485
636
  }
486
637
  /**
487
- * Sets the seconds value in the Date object using Universal Coordinated Time (UTC).
488
- * @param inputs a date and the seconds
489
- * @returns date
638
+ * Makes a copy of the date with other seconds, in UTC. The given date is not changed.
639
+ *
640
+ * Example: 14:30:00 UTC with seconds 30 -> 14:30:30 UTC
641
+ * @param inputs - The date and the seconds from 0 to 59
642
+ * @returns A new date with the seconds changed
490
643
  * @group set
491
644
  * @shortname set utc seconds
492
645
  * @drawable false
646
+ * @example
647
+ * ```typescript
648
+ * const changed = bitbybit.dates.setUTCSeconds({ date: bitbybit.dates.now(), seconds: 30 });
649
+ * ```
493
650
  */
494
651
  setUTCSeconds(inputs) {
495
652
  const dateCopy = new Date(inputs.date.getTime());
@@ -497,12 +654,18 @@ export class Dates {
497
654
  return dateCopy;
498
655
  }
499
656
  /**
500
- * Sets the milliseconds value in the Date object using Universal Coordinated Time (UTC).
501
- * @param inputs a date and the milliseconds
502
- * @returns date
657
+ * Makes a copy of the date with other milliseconds, in UTC. The given date is not changed.
658
+ *
659
+ * Example: 14:30:00.000 UTC with milliseconds 500 -> 14:30:00.500 UTC
660
+ * @param inputs - The date and the milliseconds from 0 to 999
661
+ * @returns A new date with the milliseconds changed
503
662
  * @group set
504
663
  * @shortname set utc milliseconds
505
664
  * @drawable false
665
+ * @example
666
+ * ```typescript
667
+ * const changed = bitbybit.dates.setUTCMilliseconds({ date: bitbybit.dates.now(), milliseconds: 500 });
668
+ * ```
506
669
  */
507
670
  setUTCMilliseconds(inputs) {
508
671
  const dateCopy = new Date(inputs.date.getTime());