@ehmpathy/uni-time 1.7.1 → 1.7.2

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,10 @@
1
+ import { UniDate } from '../../domain/UniDateTime';
2
+ import { castInputToDate } from '../casts/castInputToDate';
3
+ /**
4
+ * casts a date like input into a UniDate
5
+ */
6
+ export declare const asUniMonth: (input: Parameters<typeof castInputToDate>[0]) => UniDate;
7
+ /**
8
+ * checks whether a string literal input is a UniDate
9
+ */
10
+ export declare const isUniMonth: import("type-fns").AssessWithAssure<string, string & import("domain-glossaries").OfGlossary<"uni-time.UniDate">>;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isUniMonth = exports.asUniMonth = void 0;
4
+ const date_fns_1 = require("date-fns");
5
+ const type_fns_1 = require("type-fns");
6
+ const castInputToDate_1 = require("../casts/castInputToDate");
7
+ /**
8
+ * casts a date like input into a UniDate
9
+ */
10
+ const asUniMonth = (input) => (0, date_fns_1.format)((0, castInputToDate_1.castInputToDate)(input), 'yyyy-MM');
11
+ exports.asUniMonth = asUniMonth;
12
+ /**
13
+ * checks whether a string literal input is a UniDate
14
+ */
15
+ exports.isUniMonth = (0, type_fns_1.withAssure)((input) => {
16
+ try {
17
+ return (0, exports.asUniMonth)((0, date_fns_1.parseISO)(input)) === input;
18
+ }
19
+ catch (_a) {
20
+ return false;
21
+ }
22
+ });
23
+ //# sourceMappingURL=isUniMonth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isUniMonth.js","sourceRoot":"","sources":["../../../src/logic/checks/isUniMonth.ts"],"names":[],"mappings":";;;AAAA,uCAA4C;AAC5C,uCAAsC;AAGtC,8DAA2D;AAE3D;;GAEG;AACI,MAAM,UAAU,GAAG,CACxB,KAA4C,EACnC,EAAE,CAAC,IAAA,iBAAM,EAAC,IAAA,iCAAe,EAAC,KAAK,CAAC,EAAE,SAAS,CAAY,CAAC;AAFtD,QAAA,UAAU,cAE4C;AAEnE;;GAEG;AACU,QAAA,UAAU,GAAG,IAAA,qBAAU,EAAC,CAAC,KAAa,EAAoB,EAAE;IACvE,IAAI,CAAC;QACH,OAAO,IAAA,kBAAU,EAAC,IAAA,mBAAQ,EAAC,KAAK,CAAC,CAAC,KAAK,KAAK,CAAC;IAC/C,CAAC;IAAC,WAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const isUniMonth_1 = require("./isUniMonth");
4
+ describe('isUniMonth', () => {
5
+ const cases = [
6
+ {
7
+ input: 'May 15, 2024 at 5pm',
8
+ output: false,
9
+ },
10
+ {
11
+ input: '2024-05-15 17:21:55',
12
+ output: false,
13
+ },
14
+ {
15
+ input: '2024-05-15T17:21:55Z',
16
+ output: false,
17
+ },
18
+ {
19
+ input: '2024-05-15T17:21:55.555Z',
20
+ output: false,
21
+ },
22
+ {
23
+ input: 'May 15, 2024',
24
+ output: false,
25
+ },
26
+ {
27
+ input: '2024-05-15',
28
+ output: false,
29
+ },
30
+ {
31
+ input: 'May 2024',
32
+ output: false,
33
+ },
34
+ {
35
+ input: '2024-05',
36
+ output: true,
37
+ },
38
+ ];
39
+ cases.forEach((thisCase) => it(`should return ${thisCase.output} for '${thisCase.input}'`, () => {
40
+ expect((0, isUniMonth_1.isUniMonth)(thisCase.input)).toEqual(thisCase.output);
41
+ }));
42
+ });
43
+ //# sourceMappingURL=isUniMonth.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isUniMonth.test.js","sourceRoot":"","sources":["../../../src/logic/checks/isUniMonth.test.ts"],"names":[],"mappings":";;AAAA,6CAA0C;AAE1C,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,MAAM,KAAK,GAAyC;QAClD;YACE,KAAK,EAAE,qBAAqB;YAC5B,MAAM,EAAE,KAAK;SACd;QACD;YACE,KAAK,EAAE,qBAAqB;YAC5B,MAAM,EAAE,KAAK;SACd;QACD;YACE,KAAK,EAAE,sBAAsB;YAC7B,MAAM,EAAE,KAAK;SACd;QACD;YACE,KAAK,EAAE,0BAA0B;YACjC,MAAM,EAAE,KAAK;SACd;QACD;YACE,KAAK,EAAE,cAAc;YACrB,MAAM,EAAE,KAAK;SACd;QACD;YACE,KAAK,EAAE,YAAY;YACnB,MAAM,EAAE,KAAK;SACd;QACD;YACE,KAAK,EAAE,UAAU;YACjB,MAAM,EAAE,KAAK;SACd;QACD;YACE,KAAK,EAAE,SAAS;YAChB,MAAM,EAAE,IAAI;SACb;KACF,CAAC;IAEF,KAAK,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CACzB,EAAE,CAAC,iBAAiB,QAAQ,CAAC,MAAM,SAAS,QAAQ,CAAC,KAAK,GAAG,EAAE,GAAG,EAAE;QAClE,MAAM,CAAC,IAAA,uBAAU,EAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC9D,CAAC,CAAC,CACH,CAAC;AACJ,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@ehmpathy/uni-time",
3
3
  "author": "ehmpathy",
4
4
  "description": "a glossary of universally intuitive time, date, and duration domain literals",
5
- "version": "1.7.1",
5
+ "version": "1.7.2",
6
6
  "repository": "ehmpathy/uni-time",
7
7
  "homepage": "https://github.com/ehmpathy/uni-time",
8
8
  "keywords": [