@thisisagile/easy 7.43.8 → 8.0.1
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.
|
@@ -16,7 +16,7 @@ export declare class DateTime extends Value<string | undefined> {
|
|
|
16
16
|
startOf: (unit: DateTimeUnit) => DateTime;
|
|
17
17
|
endOf: (unit: DateTimeUnit) => DateTime;
|
|
18
18
|
toString(): string;
|
|
19
|
-
toLocale: (locales?: string | string[],
|
|
19
|
+
toLocale: (locales?: string | string[], format?: string) => string;
|
|
20
20
|
toFull: (...locales: string[]) => string;
|
|
21
21
|
toDate(): Date | undefined;
|
|
22
22
|
}
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.DateTime = void 0;
|
|
7
7
|
const types_1 = require("../../types");
|
|
8
8
|
const moment_1 = __importDefault(require("moment"));
|
|
9
|
+
const utils_1 = require("../../utils");
|
|
9
10
|
class DateTime extends types_1.Value {
|
|
10
11
|
constructor(value, format) {
|
|
11
12
|
super((0, types_1.tryTo)(value).is.defined().map(v => moment_1.default.utc(v, format, true).toISOString()).orElse());
|
|
@@ -14,8 +15,8 @@ class DateTime extends types_1.Value {
|
|
|
14
15
|
this.diff = (other, unit = 'days') => this.utc.diff(other.utc, unit);
|
|
15
16
|
this.startOf = (unit) => new DateTime(this.utc.startOf(unit).toISOString());
|
|
16
17
|
this.endOf = (unit) => new DateTime(this.utc.endOf(unit).toISOString());
|
|
17
|
-
this.toLocale = (locales = 'nl-NL',
|
|
18
|
-
this.toFull = (...locales) => this.toLocale(
|
|
18
|
+
this.toLocale = (locales = 'nl-NL', format = 'L') => this.utc.locale(locales).format(format);
|
|
19
|
+
this.toFull = (...locales) => this.toLocale((0, utils_1.ifNotEmpty)(locales, locales), 'LL');
|
|
19
20
|
}
|
|
20
21
|
static get now() {
|
|
21
22
|
return new DateTime(moment_1.default.utc().toISOString());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateTime.js","sourceRoot":"","sources":["../../../src/domain/values/DateTime.ts"],"names":[],"mappings":";;;;;;AAAA,uCAAsD;AACtD,oDAAwC;
|
|
1
|
+
{"version":3,"file":"DateTime.js","sourceRoot":"","sources":["../../../src/domain/values/DateTime.ts"],"names":[],"mappings":";;;;;;AAAA,uCAAsD;AACtD,oDAAwC;AACxC,uCAAyC;AAczC,MAAa,QAAS,SAAQ,aAAyB;IACrD,YAAY,KAA8B,EAAE,MAAe;QACzD,KAAK,CAAC,IAAA,aAAK,EAAC,KAAK,CAAC,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,gBAAM,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;QA+BhG,QAAG,GAAG,CAAC,CAAS,EAAE,OAAqB,MAAM,EAAY,EAAE,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;QAE9G,aAAQ,GAAG,CAAC,CAAS,EAAE,OAAqB,MAAM,EAAY,EAAE,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;QAExH,SAAI,GAAG,CAAC,KAAe,EAAE,OAAqB,MAAM,EAAU,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAEhG,YAAO,GAAG,CAAC,IAAkB,EAAY,EAAE,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;QAE/F,UAAK,GAAG,CAAC,IAAkB,EAAY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,CAAC,EAAY;QACjB,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,gBAAM,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAC/C,CAAC;IAYD,QAAQ;QACN,OAAO,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;IAC1B,CAAC;IAMD,MAAM;QACJ,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IACtD,CAAC;CACF;AAtDD,4BAsDC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thisisagile/easy",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.1",
|
|
4
4
|
"description": "Straightforward library for building domain-driven microservice architectures",
|
|
5
5
|
"author": "Sander Hoogendoorn",
|
|
6
6
|
"license": "MIT",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"access": "public"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@thisisagile/easy-test": "
|
|
34
|
+
"@thisisagile/easy-test": "8.0.1",
|
|
35
35
|
"@types/form-urlencoded": "^4.4.0",
|
|
36
36
|
"@types/jsonwebtoken": "^8.5.6",
|
|
37
37
|
"@types/validator": "^13.7.0"
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isDefined, tryTo, Value } from '../../types';
|
|
2
2
|
import moment, { Moment } from 'moment';
|
|
3
|
+
import { ifNotEmpty } from '../../utils';
|
|
3
4
|
|
|
4
5
|
export type DateTimeUnit =
|
|
5
6
|
'year' | 'years' | 'y' |
|
|
@@ -60,9 +61,9 @@ export class DateTime extends Value<string | undefined> {
|
|
|
60
61
|
return this.value ?? '';
|
|
61
62
|
}
|
|
62
63
|
|
|
63
|
-
toLocale = (locales: string | string[] = 'nl-NL',
|
|
64
|
+
toLocale = (locales: string | string[] = 'nl-NL', format = 'L'): string => this.utc.locale(locales).format(format);
|
|
64
65
|
|
|
65
|
-
toFull = (...locales: string[]): string => this.toLocale(locales,
|
|
66
|
+
toFull = (...locales: string[]): string => this.toLocale(ifNotEmpty(locales, locales), 'LL');
|
|
66
67
|
|
|
67
68
|
toDate(): Date | undefined {
|
|
68
69
|
return this.isValid ? this.utc.toDate() : undefined;
|