@docaohuynh/ielts-api-utils 1.0.9 → 1.0.10

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/dist/index.js CHANGED
@@ -7267,6 +7267,36 @@ function slugify(string, options) {
7267
7267
  var textToSlug = (text) => {
7268
7268
  return slugify(text);
7269
7269
  };
7270
+ // src/utils/date/date-compare.util.ts
7271
+ function compareDates(date1, date2) {
7272
+ if (date1 === null && date2 === null) {
7273
+ return 0;
7274
+ }
7275
+ if (date1 === null) {
7276
+ return -1;
7277
+ }
7278
+ if (date2 === null) {
7279
+ return 1;
7280
+ }
7281
+ const d1 = new Date(date1);
7282
+ const d2 = new Date(date2);
7283
+ if (d1.getTime() < d2.getTime()) {
7284
+ return -1;
7285
+ } else if (d1.getTime() > d2.getTime()) {
7286
+ return 1;
7287
+ } else {
7288
+ return 0;
7289
+ }
7290
+ }
7291
+ function isBefore(date1, date2) {
7292
+ return compareDates(date1, date2) < 0;
7293
+ }
7294
+ function isAfter(date1, date2) {
7295
+ return compareDates(date1, date2) > 0;
7296
+ }
7297
+ function isEqual(date1, date2) {
7298
+ return compareDates(date1, date2) === 0;
7299
+ }
7270
7300
  export {
7271
7301
  withTimeout,
7272
7302
  textToSlug,
@@ -7283,6 +7313,9 @@ export {
7283
7313
  replaceWordInList,
7284
7314
  removeEmptyLines,
7285
7315
  normalizeText,
7316
+ isEqual,
7317
+ isBefore,
7318
+ isAfter,
7286
7319
  getCurrentDateStr,
7287
7320
  getCurrentDateInUserTimezone,
7288
7321
  getCurrentDateFullInUserTimezone,
@@ -7295,5 +7328,6 @@ export {
7295
7328
  delayInMilliseconds,
7296
7329
  decryptText,
7297
7330
  decrypt,
7298
- decodeSignedPayload
7331
+ decodeSignedPayload,
7332
+ compareDates
7299
7333
  };
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Compares two date strings in ISO format or null values
3
+ * @param date1 - First date string in ISO format or null
4
+ * @param date2 - Second date string in ISO format or null
5
+ * @returns -1 if date1 is earlier than date2, 0 if equal, 1 if date1 is later than date2
6
+ * If either date is null, treats it as earlier than any valid date
7
+ */
8
+ export declare function compareDates(date1: string | null, date2: string | null): number;
9
+ /**
10
+ * Checks if date1 is earlier than date2
11
+ * @param date1 - First date string in ISO format or null
12
+ * @param date2 - Second date string in ISO format or null
13
+ * @returns true if date1 is earlier than date2, false otherwise
14
+ */
15
+ export declare function isBefore(date1: string | null, date2: string | null): boolean;
16
+ /**
17
+ * Checks if date1 is later than date2
18
+ * @param date1 - First date string in ISO format or null
19
+ * @param date2 - Second date string in ISO format or null
20
+ * @returns true if date1 is later than date2, false otherwise
21
+ */
22
+ export declare function isAfter(date1: string | null, date2: string | null): boolean;
23
+ /**
24
+ * Checks if two dates are equal
25
+ * @param date1 - First date string in ISO format or null
26
+ * @param date2 - Second date string in ISO format or null
27
+ * @returns true if dates are equal, false otherwise
28
+ */
29
+ export declare function isEqual(date1: string | null, date2: string | null): boolean;
@@ -0,0 +1 @@
1
+ export * from './date-compare.util';
@@ -6,3 +6,4 @@ export * from './list';
6
6
  export * from './time';
7
7
  export * from './request';
8
8
  export * from './slug';
9
+ export * from './date';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docaohuynh/ielts-api-utils",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "description": "Utilities for IELTS API",
5
5
  "module": "index.ts",
6
6
  "main": "dist/index.js",