@react-pakistan/util-functions 1.24.89 → 1.24.93

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.
@@ -0,0 +1,12 @@
1
+ interface Return {
2
+ startOfMonth: Date;
3
+ endOfMonth: Date;
4
+ }
5
+ /**
6
+ * Get the full month range for a given month and year
7
+ * @param month - The month (0-11, where 0 is January). Defaults to current month.
8
+ * @param year - The year. Defaults to current year.
9
+ * @returns An object containing startOfMonth and endOfMonth dates
10
+ */
11
+ export declare const fullMonthRange: (month?: number, year?: number) => Return;
12
+ export {};
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fullMonthRange = void 0;
4
+ /**
5
+ * Get the full month range for a given month and year
6
+ * @param month - The month (0-11, where 0 is January). Defaults to current month.
7
+ * @param year - The year. Defaults to current year.
8
+ * @returns An object containing startOfMonth and endOfMonth dates
9
+ */
10
+ var fullMonthRange = function (month, year) {
11
+ var now = new Date();
12
+ var targetYear = year !== null && year !== void 0 ? year : now.getUTCFullYear();
13
+ var targetMonth = month !== null && month !== void 0 ? month : now.getUTCMonth();
14
+ // Start of month: first day at 00:00:00.000
15
+ var startOfMonth = new Date(targetYear, targetMonth, 1, 0, 0, 0, 0);
16
+ // End of month: last day at 23:59:59.999
17
+ // Setting day to 0 of next month gives us the last day of current month
18
+ var endOfMonth = new Date(targetYear, targetMonth + 1, 0, 23, 59, 59, 999);
19
+ return {
20
+ startOfMonth: startOfMonth,
21
+ endOfMonth: endOfMonth,
22
+ };
23
+ };
24
+ exports.fullMonthRange = fullMonthRange;
@@ -2,5 +2,10 @@ interface Return {
2
2
  startOfYear: Date;
3
3
  endOfYear: Date;
4
4
  }
5
- export declare const fullYearRange: () => Return;
5
+ /**
6
+ * Get the full year range for a given year
7
+ * @param year - The year. Defaults to current year.
8
+ * @returns An object containing startOfYear and endOfYear dates
9
+ */
10
+ export declare const fullYearRange: (year?: number) => Return;
6
11
  export {};
@@ -1,10 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.fullYearRange = void 0;
4
- var fullYearRange = function () {
5
- var currentYear = new Date().getFullYear();
6
- var startOfYear = new Date(currentYear, 0, 1); // January 1st of the current year
7
- var endOfYear = new Date(currentYear, 11, 31, 23, 59, 59, 999); // December 31st, end of day
4
+ /**
5
+ * Get the full year range for a given year
6
+ * @param year - The year. Defaults to current year.
7
+ * @returns An object containing startOfYear and endOfYear dates
8
+ */
9
+ var fullYearRange = function (year) {
10
+ var targetYear = year !== null && year !== void 0 ? year : new Date().getFullYear();
11
+ // Start of year: January 1st at 00:00:00.000
12
+ var startOfYear = new Date(targetYear, 0, 1, 0, 0, 0, 0);
13
+ // End of year: December 31st at 23:59:59.999
14
+ var endOfYear = new Date(targetYear, 11, 31, 23, 59, 59, 999);
8
15
  return {
9
16
  startOfYear: startOfYear,
10
17
  endOfYear: endOfYear,
@@ -16,6 +16,7 @@ export * from './format-number';
16
16
  export * from './format-phone';
17
17
  export * from './format-pricing';
18
18
  export * from './format-time';
19
+ export * from './full-month-range';
19
20
  export * from './full-year-range';
20
21
  export * from './generate-blog-schema';
21
22
  export * from './generate-breadcrumb-schema';
package/general/index.js CHANGED
@@ -32,6 +32,7 @@ __exportStar(require("./format-number"), exports);
32
32
  __exportStar(require("./format-phone"), exports);
33
33
  __exportStar(require("./format-pricing"), exports);
34
34
  __exportStar(require("./format-time"), exports);
35
+ __exportStar(require("./full-month-range"), exports);
35
36
  __exportStar(require("./full-year-range"), exports);
36
37
  __exportStar(require("./generate-blog-schema"), exports);
37
38
  __exportStar(require("./generate-breadcrumb-schema"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-pakistan/util-functions",
3
- "version": "1.24.89",
3
+ "version": "1.24.93",
4
4
  "description": "A library of all util functions",
5
5
  "main": "index.js",
6
6
  "scripts": {