@rtorcato/js-common 2.7.0 → 2.8.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [2.8.0](https://github.com/rtorcato/js-common/compare/v2.7.0...v2.8.0) (2026-06-12)
2
+
3
+
4
+ ### Features
5
+
6
+ * **docs:** landing + footer design handoff ([#69](https://github.com/rtorcato/js-common/issues/69)) ([1e5a0d3](https://github.com/rtorcato/js-common/commit/1e5a0d3642033390c5c67cbf0df4a8116e40df76)), closes [#0a0e16](https://github.com/rtorcato/js-common/issues/0a0e16)
7
+
1
8
  # [2.7.0](https://github.com/rtorcato/js-common/compare/v2.6.0...v2.7.0) (2026-06-12)
2
9
 
3
10
 
@@ -1,44 +1,70 @@
1
1
  /**
2
2
  * Returns today's date as a YYYY-MM-DD string.
3
- * @returns {string}
4
3
  */
5
4
  export declare function today(): string;
6
5
  /**
7
- * Returns a Date object from a YYYY-MM-DD string.
8
- * @param dateStr The date string.
9
- * @returns {Date}
6
+ * Returns a Date object from a YYYY-MM-DD string (parsed as local time).
10
7
  */
11
8
  export declare function parseDate(dateStr: string): Date;
12
9
  /**
13
- * Formats a Date object as YYYY-MM-DD.
14
- * @param date The Date object.
15
- * @returns {string}
10
+ * Formats a Date object as YYYY-MM-DD (UTC).
16
11
  */
17
12
  export declare function formatDate(date: Date): string;
18
13
  /**
19
14
  * Returns the difference in days between two dates (date2 - date1).
20
- * @param date1 The first date (string or Date).
21
- * @param date2 The second date (string or Date).
22
- * @returns {number}
23
15
  */
24
16
  export declare function daysBetween(date1: string | Date, date2: string | Date): number;
17
+ /**
18
+ * Returns the difference in hours between two dates (date2 - date1).
19
+ */
20
+ export declare function diffInHours(date1: string | Date, date2: string | Date): number;
21
+ /**
22
+ * Returns the difference in minutes between two dates (date2 - date1).
23
+ */
24
+ export declare function diffInMinutes(date1: string | Date, date2: string | Date): number;
25
25
  /**
26
26
  * Checks if a year is a leap year.
27
- * @param year The year (number or Date).
28
- * @returns {boolean}
29
27
  */
30
28
  export declare function isLeapYear(year: number | Date): boolean;
31
29
  /**
32
30
  * Adds days to a date and returns a new Date object.
33
- * @param date The date (string or Date).
34
- * @param days Number of days to add.
35
- * @returns {Date}
36
31
  */
37
32
  export declare function addDays(date: string | Date, days: number): Date;
33
+ /**
34
+ * Subtracts days from a date and returns a new Date object.
35
+ */
36
+ export declare function subDays(date: string | Date, days: number): Date;
37
+ /**
38
+ * Adds months to a date and returns a new Date object.
39
+ */
40
+ export declare function addMonths(date: string | Date, months: number): Date;
38
41
  /**
39
42
  * Returns the day of the week for a date (0=Sunday, 6=Saturday).
40
- * @param date The date (string or Date).
41
- * @returns {number}
42
43
  */
43
44
  export declare function getDayOfWeek(date: string | Date): number;
45
+ /**
46
+ * Returns a new Date set to the start of the day (00:00:00.000) in local time.
47
+ */
48
+ export declare function startOfDay(date: string | Date): Date;
49
+ /**
50
+ * Returns a new Date set to the end of the day (23:59:59.999) in local time.
51
+ */
52
+ export declare function endOfDay(date: string | Date): Date;
53
+ /**
54
+ * Returns true if the date falls on Saturday or Sunday.
55
+ */
56
+ export declare function isWeekend(date: string | Date): boolean;
57
+ /**
58
+ * Returns true if the two dates fall on the same calendar day (local time).
59
+ */
60
+ export declare function isSameDay(date1: string | Date, date2: string | Date): boolean;
61
+ /**
62
+ * Returns true if the date is today (local time).
63
+ */
64
+ export declare function isToday(date: string | Date): boolean;
65
+ /**
66
+ * Formats a date as a short relative string: "today", "yesterday", "tomorrow",
67
+ * "N days ago", or "in N days". Compared against `now` (defaults to current time).
68
+ */
69
+ export declare function formatRelative(date: string | Date, now?: Date): string;
44
70
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/date/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,KAAK,IAAI,MAAM,CAG9B;AAED;;;;GAIG;AACH,wBA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EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAGvD;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAI/D;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAE/D;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAInE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAExD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAIpD;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAIlD;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAGtD;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAQ7E;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAEpD;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,GAAG,GAAE,IAAiB,GAAG,MAAM,CAQlF"}
@@ -1 +1 @@
1
- import"../chunks/chunk-ANN5UYCF.js";function i(){return new Date().toISOString().slice(0,10)}function r(t){return new Date(`${t}T00:00:00`)}function s(t){return t.toISOString().slice(0,10)}function a(t,e){let n=typeof t=="string"?r(t):t,o=typeof e=="string"?r(e):e;return Math.floor((o.getTime()-n.getTime())/(1e3*60*60*24))}function g(t){let e=t instanceof Date?t.getUTCFullYear():t;return e%4===0&&e%100!==0||e%400===0}function u(t,e){let n=typeof t=="string"?r(t):new Date(t);return n.setDate(n.getDate()+e),n}function D(t){return(typeof t=="string"?r(t):t).getDay()}export{u as addDays,a as daysBetween,s as formatDate,D as getDayOfWeek,g as isLeapYear,r as parseDate,i as today};
1
+ import"../chunks/chunk-ANN5UYCF.js";function n(t){return typeof t=="string"?s(t):new Date(t)}function c(){return new Date().toISOString().slice(0,10)}function s(t){return new Date(`${t}T00:00:00`)}function f(t){return t.toISOString().slice(0,10)}function M(t,e){return Math.floor((n(e).getTime()-n(t).getTime())/864e5)}function d(t,e){return Math.floor((n(e).getTime()-n(t).getTime())/36e5)}function _(t,e){return Math.floor((n(e).getTime()-n(t).getTime())/6e4)}function m(t){let e=t instanceof Date?t.getUTCFullYear():t;return e%4===0&&e%100!==0||e%400===0}function u(t,e){let r=n(t);return r.setDate(r.getDate()+e),r}function p(t,e){return u(t,-e)}function S(t,e){let r=n(t);return r.setMonth(r.getMonth()+e),r}function D(t){return n(t).getDay()}function i(t){let e=n(t);return e.setHours(0,0,0,0),e}function x(t){let e=n(t);return e.setHours(23,59,59,999),e}function y(t){let e=D(t);return e===0||e===6}function g(t,e){let r=n(t),a=n(e);return r.getFullYear()===a.getFullYear()&&r.getMonth()===a.getMonth()&&r.getDate()===a.getDate()}function E(t){return g(n(t),new Date)}function b(t,e=new Date){let r=i(n(t)),a=i(e),o=Math.round((r.getTime()-a.getTime())/864e5);return o===0?"today":o===1?"tomorrow":o===-1?"yesterday":o>0?`in ${o} days`:`${-o} days ago`}export{u as addDays,S as addMonths,M as daysBetween,d as diffInHours,_ as diffInMinutes,x as endOfDay,f as formatDate,b as formatRelative,D as getDayOfWeek,m as isLeapYear,g as isSameDay,E as isToday,y as isWeekend,s as parseDate,i as startOfDay,p as subDays,c as today};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtorcato/js-common",
3
- "version": "2.7.0",
3
+ "version": "2.8.0",
4
4
  "description": "JavaScript and TypeScript common code",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",