chronal 0.0.4 → 0.0.6

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 (68) hide show
  1. package/README.md +23 -23
  2. package/esm/chainable/chronal.d.ts +12 -6
  3. package/esm/chainable/chronal.d.ts.map +1 -1
  4. package/esm/chainable/chronal.js +20 -32
  5. package/esm/chainable/{date-range.d.ts → dates-until.d.ts} +6 -6
  6. package/esm/chainable/dates-until.d.ts.map +1 -0
  7. package/esm/chainable/{date-range.js → dates-until.js} +6 -6
  8. package/esm/chainable/end-of.d.ts +3 -3
  9. package/esm/chainable/end-of.d.ts.map +1 -1
  10. package/esm/chainable/end-of.js +10 -5
  11. package/esm/chainable/start-of.d.ts +3 -3
  12. package/esm/chainable/start-of.d.ts.map +1 -1
  13. package/esm/chainable/start-of.js +10 -5
  14. package/{script/chainable/sub-time.d.ts → esm/chainable/subtract.d.ts} +4 -4
  15. package/esm/chainable/subtract.d.ts.map +1 -0
  16. package/esm/chainable/{sub-time.js → subtract.js} +4 -4
  17. package/esm/lib/config.d.ts +1 -1
  18. package/esm/lib/config.d.ts.map +1 -1
  19. package/esm/lib/config.js +1 -1
  20. package/{script/lib/date-range.d.ts → esm/lib/dates-until.d.ts} +5 -5
  21. package/esm/lib/dates-until.d.ts.map +1 -0
  22. package/esm/lib/{date-range.js → dates-until.js} +4 -4
  23. package/esm/lib/parse-date.d.ts +12 -5
  24. package/esm/lib/parse-date.d.ts.map +1 -1
  25. package/esm/lib/parse-date.js +59 -5
  26. package/esm/lib/{sub-time.d.ts → subtract.d.ts} +3 -3
  27. package/esm/lib/{sub-time.d.ts.map → subtract.d.ts.map} +1 -1
  28. package/esm/lib/{sub-time.js → subtract.js} +2 -2
  29. package/esm/mod.d.ts +3 -3
  30. package/esm/mod.d.ts.map +1 -1
  31. package/esm/mod.js +3 -3
  32. package/package.json +1 -1
  33. package/script/chainable/chronal.d.ts +12 -6
  34. package/script/chainable/chronal.d.ts.map +1 -1
  35. package/script/chainable/chronal.js +20 -32
  36. package/script/chainable/{date-range.d.ts → dates-until.d.ts} +6 -6
  37. package/script/chainable/dates-until.d.ts.map +1 -0
  38. package/script/chainable/{date-range.js → dates-until.js} +7 -7
  39. package/script/chainable/end-of.d.ts +3 -3
  40. package/script/chainable/end-of.d.ts.map +1 -1
  41. package/script/chainable/end-of.js +10 -5
  42. package/script/chainable/start-of.d.ts +3 -3
  43. package/script/chainable/start-of.d.ts.map +1 -1
  44. package/script/chainable/start-of.js +10 -5
  45. package/{esm/chainable/sub-time.d.ts → script/chainable/subtract.d.ts} +4 -4
  46. package/script/chainable/subtract.d.ts.map +1 -0
  47. package/script/chainable/{sub-time.js → subtract.js} +5 -5
  48. package/script/lib/config.d.ts +1 -1
  49. package/script/lib/config.d.ts.map +1 -1
  50. package/script/lib/config.js +2 -2
  51. package/{esm/lib/date-range.d.ts → script/lib/dates-until.d.ts} +5 -5
  52. package/script/lib/dates-until.d.ts.map +1 -0
  53. package/script/lib/{date-range.js → dates-until.js} +5 -5
  54. package/script/lib/parse-date.d.ts +12 -5
  55. package/script/lib/parse-date.d.ts.map +1 -1
  56. package/script/lib/parse-date.js +59 -5
  57. package/script/lib/{sub-time.d.ts → subtract.d.ts} +3 -3
  58. package/script/lib/{sub-time.d.ts.map → subtract.d.ts.map} +1 -1
  59. package/script/lib/{sub-time.js → subtract.js} +3 -3
  60. package/script/mod.d.ts +3 -3
  61. package/script/mod.d.ts.map +1 -1
  62. package/script/mod.js +6 -6
  63. package/esm/chainable/date-range.d.ts.map +0 -1
  64. package/esm/chainable/sub-time.d.ts.map +0 -1
  65. package/esm/lib/date-range.d.ts.map +0 -1
  66. package/script/chainable/date-range.d.ts.map +0 -1
  67. package/script/chainable/sub-time.d.ts.map +0 -1
  68. package/script/lib/date-range.d.ts.map +0 -1
package/README.md CHANGED
@@ -59,7 +59,7 @@ npm install chronal
59
59
  ```
60
60
 
61
61
  ```javascript
62
- import { addTime, formatDate, subTime } from "chronal";
62
+ import { addTime, formatDate, subtract } from "chronal";
63
63
  ```
64
64
 
65
65
  ## Quick Start
@@ -79,7 +79,7 @@ import {
79
79
  isToday,
80
80
  parseDate,
81
81
  startOf,
82
- subTime,
82
+ subtract,
83
83
  } from "chronal";
84
84
 
85
85
  const date = new Date("2024-06-15T14:35:22Z");
@@ -94,7 +94,7 @@ parseDate("15/06/2024", "DD/MM/YYYY"); // Date object for June 15, 2024
94
94
 
95
95
  // Add/subtract time
96
96
  addTime(date, { days: 5, hours: 2 }); // 2024-06-20T16:35:22Z
97
- subTime(date, { months: 1, days: 10 }); // 2024-05-05T14:35:22Z
97
+ subtract(date, { months: 1, days: 10 }); // 2024-05-05T14:35:22Z
98
98
 
99
99
  // Start/End of period
100
100
  startOf(date, "month"); // 2024-06-01T00:00:00.000Z
@@ -107,7 +107,7 @@ fromNow(new Date(Date.now() - 300000)); // "5 minutes ago"
107
107
  isToday(new Date()); // true
108
108
 
109
109
  // Generate date ranges
110
- dateRange(new Date("2024-01-01"), new Date("2024-01-05"));
110
+ datesUntil(new Date("2024-01-01"), new Date("2024-01-05"));
111
111
  // [2024-01-01, 2024-01-02, 2024-01-03, 2024-01-04, 2024-01-05]
112
112
  ```
113
113
 
@@ -129,7 +129,7 @@ console.log(date); // "2024-07-01"
129
129
  // All methods available
130
130
  const result = chronal("2024-01-15")
131
131
  .add({ days: 10 })
132
- .sub({ hours: 2 })
132
+ .subtract({ hours: 2 })
133
133
  .format("MMMM DD, YYYY"); // "January 25, 2024"
134
134
 
135
135
  // Query methods
@@ -144,7 +144,7 @@ chronal("2024-06-15").daysInMonth(); // 30
144
144
 
145
145
  // Generate date ranges
146
146
  chronal("2024-01-01")
147
- .range(new Date("2024-01-31"), { weeks: 1 })
147
+ .until(new Date("2024-01-31"), { weeks: 1 })
148
148
  .map((c) => c.format("YYYY-MM-DD"));
149
149
  // ["2024-01-01", "2024-01-08", "2024-01-15", "2024-01-22", "2024-01-29"]
150
150
  ```
@@ -157,7 +157,7 @@ chronal("2024-01-01")
157
157
 
158
158
  ## Configuration
159
159
 
160
- ### `setConfig(config)`
160
+ ### `setChronalConfig(config)`
161
161
 
162
162
  Set the default configuration for all date operations.
163
163
 
@@ -169,18 +169,18 @@ Set the default configuration for all date operations.
169
169
  **Example:**
170
170
 
171
171
  ```typescript
172
- import { formatDate, months, setConfig } from "chronal";
172
+ import { formatDate, months, setChronalConfig } from "chronal";
173
173
 
174
174
  // Default is 'en-US' and 'UTC'
175
175
  formatDate(new Date("2024-06-15"), "MMMM"); // 'June'
176
176
 
177
177
  // Change default locale
178
- setConfig({ locale: "pt-BR" });
178
+ setChronalConfig({ locale: "pt-BR" });
179
179
  formatDate(new Date("2024-06-15"), "MMMM"); // 'junho'
180
180
  months(); // ['janeiro', 'fevereiro', 'março', ...]
181
181
 
182
182
  // Change default timezone
183
- setConfig({ timezone: "America/Sao_Paulo" });
183
+ setChronalConfig({ timezone: "America/Sao_Paulo" });
184
184
 
185
185
  // You can still override per call
186
186
  formatDate(new Date("2024-06-15"), "MMMM", { locale: "fr-FR" }); // 'juin'
@@ -210,7 +210,7 @@ All chainable methods correspond to functional API functions:
210
210
  | Chainable Method | Functional API | Description |
211
211
  | ------------------------- | ------------------------------------- | ------------------------ |
212
212
  | `.add(options)` | `addTime(date, options)` | Add time units |
213
- | `.subtract(options)` | `subTime(date, options)` | Subtract time units |
213
+ | `.subtract(options)` | `subtract(date, options)` | Subtract time units |
214
214
  | `.startOf(unit)` | `startOf(date, unit)` | Start of time unit |
215
215
  | `.endOf(unit)` | `endOf(date, unit)` | End of time unit |
216
216
  | `.set(options)` | `setUnit(date, options)` | Set specific units |
@@ -233,7 +233,7 @@ All chainable methods correspond to functional API functions:
233
233
  | `.quarter()` | `getQuarter(date)` | Get quarter (1-4) |
234
234
  | `.daysInMonth()` | `daysInMonth(date)` | Days in month |
235
235
  | `.week()` | `weekOfYear(date)` | Week of year |
236
- | `.range(end, step?)` | `dateRange(start, end, step?)` | Generate date array |
236
+ | `.until(end, step?)` | `datesUntil(start, end, step?)` | Generate date array |
237
237
 
238
238
  **Example:**
239
239
 
@@ -379,7 +379,7 @@ addTime(date, { months: 1 }); // 2024-02-29T12:00:00.000Z (handles leap year)
379
379
  addTime(date, { years: 1, months: 2, days: 3 }); // 2025-04-03T12:00:00.000Z
380
380
  ```
381
381
 
382
- #### `subTime(date, options)`
382
+ #### `subtract(date, options)`
383
383
 
384
384
  Subtracts specified time units from a date.
385
385
 
@@ -390,8 +390,8 @@ Subtracts specified time units from a date.
390
390
  ```typescript
391
391
  const date = new Date("2024-03-31T12:00:00Z");
392
392
 
393
- subTime(date, { days: 5 }); // 2024-03-26T12:00:00.000Z
394
- subTime(date, { months: 1 }); // 2024-02-29T12:00:00.000Z (handles month overflow)
393
+ subtract(date, { days: 5 }); // 2024-03-26T12:00:00.000Z
394
+ subtract(date, { months: 1 }); // 2024-02-29T12:00:00.000Z (handles month overflow)
395
395
  ```
396
396
 
397
397
  #### `getUnit(date, unit)`
@@ -682,7 +682,7 @@ clampDate(new Date("2024-05-15"), min, max); // June 1 (clamped to min)
682
682
  clampDate(new Date("2024-07-15"), min, max); // June 30 (clamped to max)
683
683
  ```
684
684
 
685
- #### `dateRange(start, end, step?)`
685
+ #### `datesUntil(start, end, step?)`
686
686
 
687
687
  Generates an array of dates between start and end dates with a specified step.
688
688
 
@@ -709,29 +709,29 @@ const start = new Date("2024-01-01");
709
709
  const end = new Date("2024-01-05");
710
710
 
711
711
  // Daily range (default)
712
- dateRange(start, end);
712
+ datesUntil(start, end);
713
713
  // [2024-01-01, 2024-01-02, 2024-01-03, 2024-01-04, 2024-01-05]
714
714
 
715
- // Chainable: chronal("2024-01-01").range(new Date("2024-01-05"))
715
+ // Chainable: chronal("2024-01-01").until(new Date("2024-01-05"))
716
716
 
717
717
  // Weekly range
718
718
  const weekEnd = new Date("2024-01-31");
719
- dateRange(start, weekEnd, { weeks: 1 });
719
+ datesUntil(start, weekEnd, { weeks: 1 });
720
720
  // [2024-01-01, 2024-01-08, 2024-01-15, 2024-01-22, 2024-01-29]
721
721
 
722
- // Chainable: chronal(start).range(weekEnd, { weeks: 1 })
722
+ // Chainable: chronal(start).until(weekEnd, { weeks: 1 })
723
723
 
724
724
  // Monthly range
725
725
  const monthEnd = new Date("2024-06-15");
726
- dateRange(new Date("2024-01-15"), monthEnd, { months: 1 });
726
+ datesUntil(new Date("2024-01-15"), monthEnd, { months: 1 });
727
727
  // [2024-01-15, 2024-02-15, 2024-03-15, 2024-04-15, 2024-05-15, 2024-06-15]
728
728
 
729
729
  // Every 3 days
730
- dateRange(start, new Date("2024-01-10"), { days: 3 });
730
+ datesUntil(start, new Date("2024-01-10"), { days: 3 });
731
731
  // [2024-01-01, 2024-01-04, 2024-01-07, 2024-01-10]
732
732
 
733
733
  // Hourly range
734
- dateRange(
734
+ datesUntil(
735
735
  new Date("2024-01-01T09:00:00Z"),
736
736
  new Date("2024-01-01T17:00:00Z"),
737
737
  { hours: 2 },
@@ -1,5 +1,5 @@
1
1
  import { add } from "./add.js";
2
- import { sub } from "./sub-time.js";
2
+ import { subtract } from "./subtract.js";
3
3
  import { format } from "./format.js";
4
4
  import { startOf } from "./start-of.js";
5
5
  import { endOf } from "./end-of.js";
@@ -22,7 +22,8 @@ import { getQuarter } from "./get-quarter.js";
22
22
  import { daysInMonth } from "./days-in-month.js";
23
23
  import { weekOfYear } from "./week-of-year.js";
24
24
  import { clamp } from "./clamp.js";
25
- import { dateRange } from "./date-range.js";
25
+ import { until } from "./dates-until.js";
26
+ import { setChronalConfig } from "../lib/config.js";
26
27
  /**
27
28
  * Chronal object that wraps a Date and provides chainable date manipulation methods.
28
29
  * Similar to Day.js API but built on native Date objects with immutable operations.
@@ -33,7 +34,7 @@ export type Chronal = {
33
34
  /** Adds time units to this date */
34
35
  add: typeof add;
35
36
  /** Subtracts time units from this date */
36
- sub: typeof sub;
37
+ subtract: typeof subtract;
37
38
  /** Returns the start of a time unit */
38
39
  startOf: typeof startOf;
39
40
  /** Returns the end of a time unit */
@@ -79,7 +80,7 @@ export type Chronal = {
79
80
  /** Gets the week number of the year */
80
81
  week: typeof weekOfYear;
81
82
  /** Generates an array of dates between this date and end date */
82
- range: typeof dateRange;
83
+ until: typeof until;
83
84
  };
84
85
  /**
85
86
  * Creates a Chronal object with chainable date manipulation methods.
@@ -96,7 +97,7 @@ export type Chronal = {
96
97
  * // Create from Date
97
98
  * const c = chronal(new Date('2024-06-15'));
98
99
  *
99
- * // Create from string
100
+ * // Create from string (respects config.timezone)
100
101
  * const c2 = chronal('2024-06-15T12:00:00Z');
101
102
  *
102
103
  * // Chain operations
@@ -106,5 +107,10 @@ export type Chronal = {
106
107
  * .format('YYYY-MM-DD'); // '2024-03-25'
107
108
  * ```
108
109
  */
109
- export declare const chronal: (date?: Date | string | number) => Chronal;
110
+ type ChronalFactory = {
111
+ (date?: Date | string | number | null): Chronal;
112
+ config: typeof setChronalConfig;
113
+ };
114
+ export declare const chronal: ChronalFactory;
115
+ export {};
110
116
  //# sourceMappingURL=chronal.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"chronal.d.ts","sourceRoot":"","sources":["../../src/chainable/chronal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,QAAQ,E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U,CAAC;IAGxB,iEAAiE;IACjE,KAAK,EAAE,OAAO,KAAK,CAAC;CACrB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,KAAK,cAAc,GAAG;IACpB,CAAC,IAAI,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC;IAChD,MAAM,EAAE,OAAO,gBAAgB,CAAC;CACjC,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,cA+FrB,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { add } from "./add.js";
2
- import { sub } from "./sub-time.js";
2
+ import { subtract } from "./subtract.js";
3
3
  import { format } from "./format.js";
4
4
  import { startOf } from "./start-of.js";
5
5
  import { endOf } from "./end-of.js";
@@ -22,42 +22,29 @@ import { getQuarter } from "./get-quarter.js";
22
22
  import { daysInMonth } from "./days-in-month.js";
23
23
  import { weekOfYear } from "./week-of-year.js";
24
24
  import { clamp } from "./clamp.js";
25
- import { dateRange } from "./date-range.js";
26
- /**
27
- * Creates a Chronal object with chainable date manipulation methods.
28
- * All methods return new instances, preserving immutability.
29
- *
30
- * @param date - Optional Date, string, or timestamp. Defaults to current date/time
31
- * @returns A Chronal object with the date and chainable methods
32
- *
33
- * @example
34
- * ```typescript
35
- * // Create from current time
36
- * const now = chronal();
37
- *
38
- * // Create from Date
39
- * const c = chronal(new Date('2024-06-15'));
40
- *
41
- * // Create from string
42
- * const c2 = chronal('2024-06-15T12:00:00Z');
43
- *
44
- * // Chain operations
45
- * chronal('2024-01-15')
46
- * .add({ months: 2, days: 10 })
47
- * .startOf('day')
48
- * .format('YYYY-MM-DD'); // '2024-03-25'
49
- * ```
50
- */
25
+ import { until } from "./dates-until.js";
26
+ import { parseDate } from "../lib/parse-date.js";
27
+ import { setChronalConfig } from "../lib/config.js";
51
28
  export const chronal = (date) => {
52
- const d = date ? new Date(date) : new Date();
29
+ let d;
30
+ if (date === null || date === undefined) {
31
+ d = new Date();
32
+ }
33
+ else if (typeof date === "string") {
34
+ // Parse string with timezone awareness from config
35
+ d = parseDate(date);
36
+ }
37
+ else {
38
+ d = new Date(date);
39
+ }
53
40
  return {
54
41
  date: d,
55
42
  // Manipulation
56
43
  add: function (opt) {
57
44
  return add.call(this, opt);
58
45
  },
59
- sub: function (opt) {
60
- return sub.call(this, opt);
46
+ subtract: function (opt) {
47
+ return subtract.call(this, opt);
61
48
  },
62
49
  startOf: function (unit) {
63
50
  return startOf.call(this, unit);
@@ -129,8 +116,9 @@ export const chronal = (date) => {
129
116
  return weekOfYear.call(this);
130
117
  },
131
118
  // Utilities
132
- range: function (end, step) {
133
- return dateRange.call(this, end, step);
119
+ until: function (end, step) {
120
+ return until.call(this, end, step);
134
121
  },
135
122
  };
136
123
  };
124
+ chronal.config = setChronalConfig;
@@ -1,4 +1,4 @@
1
- import { dateRange as _dateRange } from "../lib/date-range.js";
1
+ import { datesUntil as _datesUntil } from "../lib/dates-until.js";
2
2
  import { type Chronal } from "./chronal.js";
3
3
  /**
4
4
  * Generates an array of Chronal objects between this date and an end date with a specified step.
@@ -12,12 +12,12 @@ import { type Chronal } from "./chronal.js";
12
12
  * const start = chronal("2024-01-01");
13
13
  * const end = new Date("2024-01-05");
14
14
  *
15
- * start.range(end); // Array of 5 Chronal objects (Jan 1-5)
16
- * start.range(end, { days: 2 }); // Array of 3 Chronal objects (Jan 1, 3, 5)
15
+ * start.until(end); // Array of 5 Chronal objects (Jan 1-5)
16
+ * start.until(end, { days: 2 }); // Array of 3 Chronal objects (Jan 1, 3, 5)
17
17
  *
18
18
  * // Weekly range
19
- * chronal("2024-01-01").range(new Date("2024-01-31"), { weeks: 1 });
19
+ * chronal("2024-01-01").until(new Date("2024-01-31"), { weeks: 1 });
20
20
  * ```
21
21
  */
22
- export declare function dateRange(this: Chronal, end: Date | Chronal, step?: Parameters<typeof _dateRange>[2]): Chronal[];
23
- //# sourceMappingURL=date-range.d.ts.map
22
+ export declare function until(this: Chronal, end: Date | Chronal, step?: Parameters<typeof _datesUntil>[2]): Chronal[];
23
+ //# sourceMappingURL=dates-until.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dates-until.d.ts","sourceRoot":"","sources":["../../src/chainable/dates-until.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,IAAI,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,KAAK,OAAO,EAAW,MAAM,cAAc,CAAC;AAErD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,KAAK,CACnB,IAAI,EAAE,OAAO,EACb,GAAG,EAAE,IAAI,GAAG,OAAO,EACnB,IAAI,CAAC,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC,GACvC,OAAO,EAAE,CAIX"}
@@ -1,4 +1,4 @@
1
- import { dateRange as _dateRange } from "../lib/date-range.js";
1
+ import { datesUntil as _datesUntil } from "../lib/dates-until.js";
2
2
  import { chronal } from "./chronal.js";
3
3
  /**
4
4
  * Generates an array of Chronal objects between this date and an end date with a specified step.
@@ -12,15 +12,15 @@ import { chronal } from "./chronal.js";
12
12
  * const start = chronal("2024-01-01");
13
13
  * const end = new Date("2024-01-05");
14
14
  *
15
- * start.range(end); // Array of 5 Chronal objects (Jan 1-5)
16
- * start.range(end, { days: 2 }); // Array of 3 Chronal objects (Jan 1, 3, 5)
15
+ * start.until(end); // Array of 5 Chronal objects (Jan 1-5)
16
+ * start.until(end, { days: 2 }); // Array of 3 Chronal objects (Jan 1, 3, 5)
17
17
  *
18
18
  * // Weekly range
19
- * chronal("2024-01-01").range(new Date("2024-01-31"), { weeks: 1 });
19
+ * chronal("2024-01-01").until(new Date("2024-01-31"), { weeks: 1 });
20
20
  * ```
21
21
  */
22
- export function dateRange(end, step) {
22
+ export function until(end, step) {
23
23
  const endDate = end instanceof Date ? end : end.date;
24
- const dates = _dateRange(this.date, endDate, step);
24
+ const dates = _datesUntil(this.date, endDate, step);
25
25
  return dates.map((date) => chronal(date));
26
26
  }
@@ -4,13 +4,13 @@ import { type Chronal } from "./chronal.js";
4
4
  * Returns the end of the specified time unit.
5
5
  *
6
6
  * @param unit - The time unit ('year' | 'month' | 'day' | 'hour' | 'minute' | 'second')
7
- * @param timezone - Optional IANA timezone string (e.g., 'America/Sao_Paulo'). Defaults to 'UTC'.
7
+ * @param timezone - Optional IANA timezone string (e.g., 'America/Sao_Paulo'). Defaults to config.timezone.
8
8
  * @returns A new Chronal instance set to the end of the specified unit (last millisecond)
9
9
  * @example
10
10
  * ```typescript
11
11
  * const c = chronal('2024-06-15T14:35:22.500Z');
12
- * c.endOf('day'); // '2024-06-15T23:59:59.999Z'
13
- * c.endOf('day', 'America/Sao_Paulo'); // '2024-06-16T02:59:59.999Z'
12
+ * c.endOf('day'); // Uses config.timezone
13
+ * c.endOf('day', { tz: 'America/Sao_Paulo' }); // '2024-06-16T02:59:59.999Z'
14
14
  * ```
15
15
  */
16
16
  export declare function endOf(this: Chronal, unit: Parameters<typeof _endOf>[1], opt?: Parameters<typeof _endOf>[2]): Chronal;
@@ -1 +1 @@
1
- {"version":3,"file":"end-of.d.ts","sourceRoot":"","sources":["../../src/chainable/end-of.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,KAAK,OAAO,EAAW,MAAM,cAAc,CAAC;AAErD;;;;;;;;;;;;GAYG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,CAAC,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,GAAE,UAAU,CAAC,OAAO,MAAM,CAAC,CAAC,CAAC,CAAM,GAAG,OAAO,CAGxH"}
1
+ {"version":3,"file":"end-of.d.ts","sourceRoot":"","sources":["../../src/chainable/end-of.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,KAAK,OAAO,EAAW,MAAM,cAAc,CAAC;AAGrD;;;;;;;;;;;;GAYG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,CAAC,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,UAAU,CAAC,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAOpH"}
@@ -1,19 +1,24 @@
1
1
  import { endOf as _endOf } from "../lib/end-of.js";
2
2
  import { chronal } from "./chronal.js";
3
+ import { config } from "../lib/config.js";
3
4
  /**
4
5
  * Returns the end of the specified time unit.
5
6
  *
6
7
  * @param unit - The time unit ('year' | 'month' | 'day' | 'hour' | 'minute' | 'second')
7
- * @param timezone - Optional IANA timezone string (e.g., 'America/Sao_Paulo'). Defaults to 'UTC'.
8
+ * @param timezone - Optional IANA timezone string (e.g., 'America/Sao_Paulo'). Defaults to config.timezone.
8
9
  * @returns A new Chronal instance set to the end of the specified unit (last millisecond)
9
10
  * @example
10
11
  * ```typescript
11
12
  * const c = chronal('2024-06-15T14:35:22.500Z');
12
- * c.endOf('day'); // '2024-06-15T23:59:59.999Z'
13
- * c.endOf('day', 'America/Sao_Paulo'); // '2024-06-16T02:59:59.999Z'
13
+ * c.endOf('day'); // Uses config.timezone
14
+ * c.endOf('day', { tz: 'America/Sao_Paulo' }); // '2024-06-16T02:59:59.999Z'
14
15
  * ```
15
16
  */
16
- export function endOf(unit, opt = {}) {
17
- const newDate = _endOf(this.date, unit, opt);
17
+ export function endOf(unit, opt) {
18
+ const options = opt || {};
19
+ if (!options.tz) {
20
+ options.tz = config.timezone;
21
+ }
22
+ const newDate = _endOf(this.date, unit, options);
18
23
  return chronal(newDate);
19
24
  }
@@ -4,13 +4,13 @@ import { type Chronal } from "./chronal.js";
4
4
  * Returns the start of the specified time unit.
5
5
  *
6
6
  * @param unit - The time unit ('year' | 'month' | 'day' | 'hour' | 'minute' | 'second')
7
- * @param timezone - Optional IANA timezone string (e.g., 'America/Sao_Paulo'). Defaults to 'UTC'.
7
+ * @param timezone - Optional IANA timezone string (e.g., 'America/Sao_Paulo'). Defaults to config.timezone.
8
8
  * @returns A new Chronal instance set to the start of the specified unit
9
9
  * @example
10
10
  * ```typescript
11
11
  * const c = chronal('2024-06-15T14:35:22.500Z');
12
- * c.startOf('day'); // '2024-06-15T00:00:00.000Z'
13
- * c.startOf('day', 'America/Sao_Paulo'); // '2024-06-15T03:00:00.000Z'
12
+ * c.startOf('day'); // Uses config.timezone
13
+ * c.startOf('day', { tz: 'America/Sao_Paulo' }); // '2024-06-15T03:00:00.000Z'
14
14
  * ```
15
15
  */
16
16
  export declare function startOf(this: Chronal, unit: Parameters<typeof _startOf>[1], opt?: Parameters<typeof _startOf>[2]): Chronal;
@@ -1 +1 @@
1
- {"version":3,"file":"start-of.d.ts","sourceRoot":"","sources":["../../src/chainable/start-of.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,KAAK,OAAO,EAAW,MAAM,cAAc,CAAC;AAErD;;;;;;;;;;;;GAYG;AACH,wBAAgB,OAAO,CACrB,IAAI,EAAE,OAAO,EACb,IAAI,EAAE,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,EACpC,GAAG,GAAE,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAM,GACvC,OAAO,CAGT"}
1
+ {"version":3,"file":"start-of.d.ts","sourceRoot":"","sources":["../../src/chainable/start-of.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,KAAK,OAAO,EAAW,MAAM,cAAc,CAAC;AAGrD;;;;;;;;;;;;GAYG;AACH,wBAAgB,OAAO,CACrB,IAAI,EAAE,OAAO,EACb,IAAI,EAAE,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,EACpC,GAAG,CAAC,EAAE,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,GACnC,OAAO,CAOT"}
@@ -1,19 +1,24 @@
1
1
  import { startOf as _startOf } from "../lib/start-of.js";
2
2
  import { chronal } from "./chronal.js";
3
+ import { config } from "../lib/config.js";
3
4
  /**
4
5
  * Returns the start of the specified time unit.
5
6
  *
6
7
  * @param unit - The time unit ('year' | 'month' | 'day' | 'hour' | 'minute' | 'second')
7
- * @param timezone - Optional IANA timezone string (e.g., 'America/Sao_Paulo'). Defaults to 'UTC'.
8
+ * @param timezone - Optional IANA timezone string (e.g., 'America/Sao_Paulo'). Defaults to config.timezone.
8
9
  * @returns A new Chronal instance set to the start of the specified unit
9
10
  * @example
10
11
  * ```typescript
11
12
  * const c = chronal('2024-06-15T14:35:22.500Z');
12
- * c.startOf('day'); // '2024-06-15T00:00:00.000Z'
13
- * c.startOf('day', 'America/Sao_Paulo'); // '2024-06-15T03:00:00.000Z'
13
+ * c.startOf('day'); // Uses config.timezone
14
+ * c.startOf('day', { tz: 'America/Sao_Paulo' }); // '2024-06-15T03:00:00.000Z'
14
15
  * ```
15
16
  */
16
- export function startOf(unit, opt = {}) {
17
- const newDate = _startOf(this.date, unit, opt);
17
+ export function startOf(unit, opt) {
18
+ const options = opt || {};
19
+ if (!options.tz) {
20
+ options.tz = config.timezone;
21
+ }
22
+ const newDate = _startOf(this.date, unit, options);
18
23
  return chronal(newDate);
19
24
  }
@@ -1,4 +1,4 @@
1
- import { subTime as _subTime } from "../lib/sub-time.js";
1
+ import { subtract as _subtract } from "../lib/subtract.js";
2
2
  import { type Chronal } from "./chronal.js";
3
3
  /**
4
4
  * Subtracts specified time units from the date.
@@ -8,8 +8,8 @@ import { type Chronal } from "./chronal.js";
8
8
  * @example
9
9
  * ```typescript
10
10
  * const c = chronal('2024-03-31T12:00:00Z');
11
- * c.sub({ years: 1, months: 1 }); // '2023-02-28T12:00:00.000Z'
11
+ * c.subtract({ years: 1, months: 1 }); // '2023-02-28T12:00:00.000Z'
12
12
  * ```
13
13
  */
14
- export declare function sub(this: Chronal, opt: Parameters<typeof _subTime>[1]): Chronal;
15
- //# sourceMappingURL=sub-time.d.ts.map
14
+ export declare function subtract(this: Chronal, opt: Parameters<typeof _subtract>[1]): Chronal;
15
+ //# sourceMappingURL=subtract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subtract.d.ts","sourceRoot":"","sources":["../../src/chainable/subtract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,KAAK,OAAO,EAAW,MAAM,cAAc,CAAC;AAErD;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CACtB,IAAI,EAAE,OAAO,EACb,GAAG,EAAE,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC,GACnC,OAAO,CAGT"}
@@ -1,4 +1,4 @@
1
- import { subTime as _subTime } from "../lib/sub-time.js";
1
+ import { subtract as _subtract } from "../lib/subtract.js";
2
2
  import { chronal } from "./chronal.js";
3
3
  /**
4
4
  * Subtracts specified time units from the date.
@@ -8,10 +8,10 @@ import { chronal } from "./chronal.js";
8
8
  * @example
9
9
  * ```typescript
10
10
  * const c = chronal('2024-03-31T12:00:00Z');
11
- * c.sub({ years: 1, months: 1 }); // '2023-02-28T12:00:00.000Z'
11
+ * c.subtract({ years: 1, months: 1 }); // '2023-02-28T12:00:00.000Z'
12
12
  * ```
13
13
  */
14
- export function sub(opt) {
15
- const newDate = _subTime(this.date, opt);
14
+ export function subtract(opt) {
15
+ const newDate = _subtract(this.date, opt);
16
16
  return chronal(newDate);
17
17
  }
@@ -3,6 +3,6 @@ type Config = {
3
3
  timezone: string;
4
4
  };
5
5
  export declare const config: Config;
6
- export declare function setConfig(c: Partial<Config>): void;
6
+ export declare function setChronalConfig(c: Partial<Config>): void;
7
7
  export {};
8
8
  //# sourceMappingURL=config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":"AAGA,KAAK,MAAM,GAAG;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,MAGpB,CAAA;AAED,wBAAgB,SAAS,CAAC,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,QAQ3C"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":"AAGA,KAAK,MAAM,GAAG;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,MAGpB,CAAA;AAED,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,QAQlD"}
package/esm/lib/config.js CHANGED
@@ -4,7 +4,7 @@ export const config = {
4
4
  locale: DEFAULT_LOCALE,
5
5
  timezone: DEFAULT_TZ,
6
6
  };
7
- export function setConfig(c) {
7
+ export function setChronalConfig(c) {
8
8
  if (c.locale) {
9
9
  config.locale = c.locale;
10
10
  }
@@ -21,15 +21,15 @@ type RangeStep = {
21
21
  * const start = new Date("2024-01-01");
22
22
  * const end = new Date("2024-01-05");
23
23
  *
24
- * dateRange(start, end); // Array of 5 dates (Jan 1-5)
25
- * dateRange(start, end, { days: 2 }); // Array of 3 dates (Jan 1, 3, 5)
24
+ * datesUntil(start, end); // Array of 5 dates (Jan 1-5)
25
+ * datesUntil(start, end, { days: 2 }); // Array of 3 dates (Jan 1, 3, 5)
26
26
  *
27
27
  * // Weekly range
28
28
  * const weekStart = new Date("2024-01-01");
29
29
  * const weekEnd = new Date("2024-01-31");
30
- * dateRange(weekStart, weekEnd, { weeks: 1 }); // Array of 5 dates (every Monday)
30
+ * datesUntil(weekStart, weekEnd, { weeks: 1 }); // Array of 5 dates (every Monday)
31
31
  * ```
32
32
  */
33
- export declare function dateRange(start: Date, end: Date, step?: RangeStep): Date[];
33
+ export declare function datesUntil(start: Date, end: Date, step?: RangeStep): Date[];
34
34
  export {};
35
- //# sourceMappingURL=date-range.d.ts.map
35
+ //# sourceMappingURL=dates-until.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dates-until.d.ts","sourceRoot":"","sources":["../../src/lib/dates-until.ts"],"names":[],"mappings":"AAAA,KAAK,SAAS,GAAG;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,IAAI,EACX,GAAG,EAAE,IAAI,EACT,IAAI,GAAE,SAAuB,GAC5B,IAAI,EAAE,CAuFR"}
@@ -11,16 +11,16 @@
11
11
  * const start = new Date("2024-01-01");
12
12
  * const end = new Date("2024-01-05");
13
13
  *
14
- * dateRange(start, end); // Array of 5 dates (Jan 1-5)
15
- * dateRange(start, end, { days: 2 }); // Array of 3 dates (Jan 1, 3, 5)
14
+ * datesUntil(start, end); // Array of 5 dates (Jan 1-5)
15
+ * datesUntil(start, end, { days: 2 }); // Array of 3 dates (Jan 1, 3, 5)
16
16
  *
17
17
  * // Weekly range
18
18
  * const weekStart = new Date("2024-01-01");
19
19
  * const weekEnd = new Date("2024-01-31");
20
- * dateRange(weekStart, weekEnd, { weeks: 1 }); // Array of 5 dates (every Monday)
20
+ * datesUntil(weekStart, weekEnd, { weeks: 1 }); // Array of 5 dates (every Monday)
21
21
  * ```
22
22
  */
23
- export function dateRange(start, end, step = { days: 1 }) {
23
+ export function datesUntil(start, end, step = { days: 1 }) {
24
24
  const result = [];
25
25
  const startTime = start.getTime();
26
26
  const endTime = end.getTime();
@@ -1,17 +1,24 @@
1
+ type ParseDateOptions = {
2
+ format?: string;
3
+ tz?: string;
4
+ };
1
5
  /**
2
6
  * Parses a date string into a Date object using an optional format pattern.
7
+ * If timezone is specified, the string is interpreted as local time in that timezone.
3
8
  *
4
9
  * @param dateString - The date string to parse
5
- * @param format - Optional format pattern (e.g., "YYYY-MM-DD", "DD/MM/YYYY")
10
+ * @param options - Optional format pattern and/or timezone
6
11
  * @returns A Date object
7
12
  * @throws Error if the date string is invalid or doesn't match the format
8
13
  *
9
14
  * @example
10
15
  * ```typescript
11
- * parseDate("2024-06-15"); // Uses native Date parser
12
- * parseDate("15/06/2024", "DD/MM/YYYY"); // Parses with custom format
13
- * parseDate("2024-06-15 14:30:00", "YYYY-MM-DD HH:mm:ss");
16
+ * parseDate("2024-06-15"); // Uses native Date parser in UTC
17
+ * parseDate("15/06/2024", { format: "DD/MM/YYYY" }); // Parses with custom format
18
+ * parseDate("2024-06-15 14:30:00", { format: "YYYY-MM-DD HH:mm:ss" });
19
+ * parseDate("2025-04-01", { tz: "America/Sao_Paulo" }); // Parse as São Paulo time
14
20
  * ```
15
21
  */
16
- export declare function parseDate(dateString: string, format?: string): Date;
22
+ export declare function parseDate(dateString: string, options?: string | ParseDateOptions): Date;
23
+ export {};
17
24
  //# sourceMappingURL=parse-date.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"parse-date.d.ts","sourceRoot":"","sources":["../../src/lib/parse-date.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CA+EnE"}
1
+ {"version":3,"file":"parse-date.d.ts","sourceRoot":"","sources":["../../src/lib/parse-date.ts"],"names":[],"mappings":"AAGA,KAAK,gBAAgB,GAAG;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,SAAS,CACvB,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,MAAM,GAAG,gBAAgB,GAClC,IAAI,CA0FN"}