@8ms/helpers 2.0.34 → 2.0.36

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.
Binary file
@@ -22,6 +22,25 @@ const getDate = (input, setMidnight) => {
22
22
  else if (input instanceof luxon_1.DateTime) {
23
23
  instance = input.toUTC();
24
24
  }
25
+ else if ("number" === typeof input) {
26
+ // Handle different numeric formats
27
+ if (input >= 19000101 && input <= 99991231) {
28
+ // YYYYMMDD format (e.g., 20231225)
29
+ const dateStr = input.toString();
30
+ const year = parseInt(dateStr.substring(0, 4));
31
+ const month = parseInt(dateStr.substring(4, 6));
32
+ const day = parseInt(dateStr.substring(6, 8));
33
+ instance = luxon_1.DateTime.fromObject({ year, month, day }, { zone: "utc" });
34
+ }
35
+ else if (input < 10000000000) {
36
+ // Unix timestamp in seconds
37
+ instance = luxon_1.DateTime.fromSeconds(input, { zone: "utc" });
38
+ }
39
+ else {
40
+ // Unix timestamp in milliseconds
41
+ instance = luxon_1.DateTime.fromMillis(input, { zone: "utc" });
42
+ }
43
+ }
25
44
  else {
26
45
  instance = luxon_1.DateTime.fromISO(input.toString(), { zone: "utc" });
27
46
  if (!instance.isValid) {
@@ -138,7 +157,8 @@ const getMonthsBetween = (start, end) => {
138
157
  const endDate = (0, exports.getDate)(end)
139
158
  .startOf("month");
140
159
  // Start from the 1st of the month containing startDate
141
- let current = (0, exports.getDate)(start).startOf("month");
160
+ let current = (0, exports.getDate)(start)
161
+ .startOf("month");
142
162
  while (current <= endDate) {
143
163
  months.push(current);
144
164
  // Move to next month
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@8ms/helpers",
3
3
  "license": "UNLICENSED",
4
- "version": "2.0.34",
4
+ "version": "2.0.36",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/8millionstories-organisation/8ms-helpers-ts.git"