@finnair/v-validation-luxon 1.1.0-alpha.6 → 1.1.0-alpha.9
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 +24 -0
- package/dist/Vluxon.d.ts +3 -3
- package/dist/Vluxon.js +69 -78
- package/dist/luxon.d.ts +31 -13
- package/dist/luxon.js +27 -6
- package/dist/test-luxon.js +1 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,30 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [1.1.0-alpha.9](https://github.com/finnair/v-validation/compare/v1.1.0-alpha.8...v1.1.0-alpha.9) (2022-08-19)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @finnair/v-validation-luxon
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [1.1.0-alpha.8](https://github.com/finnair/v-validation/compare/v1.1.0-alpha.7...v1.1.0-alpha.8) (2022-08-19)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @finnair/v-validation-luxon
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# [1.1.0-alpha.7](https://github.com/finnair/v-validation/compare/v1.1.0-alpha.6...v1.1.0-alpha.7) (2022-08-18)
|
|
23
|
+
|
|
24
|
+
**Note:** Version bump only for package @finnair/v-validation-luxon
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
6
30
|
# [1.1.0-alpha.6](https://github.com/finnair/v-validation/compare/v1.0.1...v1.1.0-alpha.6) (2022-08-17)
|
|
7
31
|
|
|
8
32
|
|
package/dist/Vluxon.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ValidationContext, Validator, ValidationResult } from '@finnair/v-validation';
|
|
2
2
|
import { Path } from '@finnair/path';
|
|
3
|
-
import { DateTime
|
|
3
|
+
import { DateTime } from 'luxon';
|
|
4
4
|
import { LuxonDateTime } from './luxon';
|
|
5
5
|
export declare type LuxonInput = string | DateTime | LuxonDateTime;
|
|
6
6
|
export interface ValidateLuxonParams {
|
|
@@ -10,9 +10,9 @@ export interface ValidateLuxonParams {
|
|
|
10
10
|
type: string;
|
|
11
11
|
proto: any;
|
|
12
12
|
pattern: RegExp;
|
|
13
|
-
|
|
13
|
+
parser: (value: string, match: RegExpExecArray) => DateTime;
|
|
14
14
|
}
|
|
15
|
-
export declare function validateLuxon({ value, path, ctx, type, proto, pattern,
|
|
15
|
+
export declare function validateLuxon({ value, path, ctx, type, proto, pattern, parser }: ValidateLuxonParams): Promise<ValidationResult>;
|
|
16
16
|
export declare class DurationValidator extends Validator {
|
|
17
17
|
validatePath(value: any, path: Path, ctx: ValidationContext): Promise<ValidationResult>;
|
|
18
18
|
}
|
package/dist/Vluxon.js
CHANGED
|
@@ -13,109 +13,100 @@ exports.Vluxon = exports.DurationValidator = exports.validateLuxon = void 0;
|
|
|
13
13
|
const v_validation_1 = require("@finnair/v-validation");
|
|
14
14
|
const luxon_1 = require("luxon");
|
|
15
15
|
const luxon_2 = require("./luxon");
|
|
16
|
-
function validateLuxon({ value, path, ctx, type, proto, pattern,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if (value instanceof proto) {
|
|
21
|
-
return ctx.success(value);
|
|
22
|
-
}
|
|
23
|
-
else if (luxon_1.DateTime.isDateTime(value)) {
|
|
24
|
-
if (value.isValid) {
|
|
25
|
-
return ctx.success(new proto(value));
|
|
16
|
+
function validateLuxon({ value, path, ctx, type, proto, pattern, parser }) {
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
if ((0, v_validation_1.isNullOrUndefined)(value)) {
|
|
19
|
+
return ctx.failure(v_validation_1.defaultViolations.notNull(path), value);
|
|
26
20
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (
|
|
32
|
-
return ctx.success(new proto(
|
|
21
|
+
if (value instanceof proto) {
|
|
22
|
+
return ctx.success(value);
|
|
23
|
+
}
|
|
24
|
+
else if (luxon_1.DateTime.isDateTime(value)) {
|
|
25
|
+
if (value.isValid) {
|
|
26
|
+
return ctx.success(new proto(value));
|
|
33
27
|
}
|
|
34
28
|
}
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
else if ((0, v_validation_1.isString)(value)) {
|
|
30
|
+
const match = pattern.exec(value);
|
|
31
|
+
if (match) {
|
|
32
|
+
const dateTime = parser(value, match);
|
|
33
|
+
if (dateTime.isValid) {
|
|
34
|
+
return ctx.success(new proto(dateTime));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return ctx.failure(v_validation_1.defaultViolations.date(value, path, type), value);
|
|
39
|
+
});
|
|
37
40
|
}
|
|
38
41
|
exports.validateLuxon = validateLuxon;
|
|
39
42
|
const datePattern = /^\d{4}-\d{2}-\d{2}$/;
|
|
40
43
|
function localDateValidator(value, path, ctx) {
|
|
41
|
-
return
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
options: { zone: luxon_1.FixedOffsetZone.utcInstance },
|
|
50
|
-
});
|
|
44
|
+
return validateLuxon({
|
|
45
|
+
value,
|
|
46
|
+
path,
|
|
47
|
+
ctx,
|
|
48
|
+
type: 'Date',
|
|
49
|
+
proto: luxon_2.LocalDateLuxon,
|
|
50
|
+
pattern: datePattern,
|
|
51
|
+
parser: (value) => luxon_1.DateTime.fromISO(value, { zone: luxon_1.FixedOffsetZone.utcInstance }),
|
|
51
52
|
});
|
|
52
53
|
}
|
|
53
54
|
const timePattern = /^\d{2}:\d{2}:\d{2}$/;
|
|
54
55
|
function localTimeValidator(value, path, ctx) {
|
|
55
|
-
return
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
options: { zone: luxon_1.FixedOffsetZone.utcInstance },
|
|
64
|
-
});
|
|
56
|
+
return validateLuxon({
|
|
57
|
+
value,
|
|
58
|
+
path,
|
|
59
|
+
ctx,
|
|
60
|
+
type: 'Time',
|
|
61
|
+
proto: luxon_2.LocalTimeLuxon,
|
|
62
|
+
pattern: timePattern,
|
|
63
|
+
parser: (value) => luxon_1.DateTime.fromISO(value, { zone: luxon_1.FixedOffsetZone.utcInstance }),
|
|
65
64
|
});
|
|
66
65
|
}
|
|
67
66
|
const dateTimePattern = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:Z|[+-]\d{2}(?::?\d{2})?)$/;
|
|
68
67
|
function dateTimeValidator(value, path, ctx) {
|
|
69
|
-
return
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
options: { setZone: true },
|
|
78
|
-
});
|
|
68
|
+
return validateLuxon({
|
|
69
|
+
value,
|
|
70
|
+
path,
|
|
71
|
+
ctx,
|
|
72
|
+
type: 'DateTime',
|
|
73
|
+
proto: luxon_2.DateTimeLuxon,
|
|
74
|
+
pattern: dateTimePattern,
|
|
75
|
+
parser: (value) => luxon_1.DateTime.fromISO(value, { setZone: true }),
|
|
79
76
|
});
|
|
80
77
|
}
|
|
81
78
|
function dateTimeUtcValidator(value, path, ctx) {
|
|
82
|
-
return
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
options: { zone: luxon_1.FixedOffsetZone.utcInstance },
|
|
91
|
-
});
|
|
79
|
+
return validateLuxon({
|
|
80
|
+
value,
|
|
81
|
+
path,
|
|
82
|
+
ctx,
|
|
83
|
+
type: 'DateTime',
|
|
84
|
+
proto: luxon_2.DateTimeUtcLuxon,
|
|
85
|
+
pattern: dateTimePattern,
|
|
86
|
+
parser: (value) => luxon_1.DateTime.fromISO(value, { zone: luxon_1.FixedOffsetZone.utcInstance }),
|
|
92
87
|
});
|
|
93
88
|
}
|
|
94
89
|
const dateTimeMillisPattern = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}(?:Z|[+-]\d{2}(?::?\d{2})?)$/;
|
|
95
90
|
function dateTimeMillisValidator(value, path, ctx) {
|
|
96
|
-
return
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
options: { setZone: true },
|
|
105
|
-
});
|
|
91
|
+
return validateLuxon({
|
|
92
|
+
value,
|
|
93
|
+
path,
|
|
94
|
+
ctx,
|
|
95
|
+
type: 'DateTimeMillis',
|
|
96
|
+
proto: luxon_2.DateTimeMillisLuxon,
|
|
97
|
+
pattern: dateTimeMillisPattern,
|
|
98
|
+
parser: (value) => luxon_1.DateTime.fromISO(value, { setZone: true }),
|
|
106
99
|
});
|
|
107
100
|
}
|
|
108
101
|
function dateTimeMillisUtcValidator(value, path, ctx) {
|
|
109
|
-
return
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
options: { zone: luxon_1.FixedOffsetZone.utcInstance },
|
|
118
|
-
});
|
|
102
|
+
return validateLuxon({
|
|
103
|
+
value,
|
|
104
|
+
path,
|
|
105
|
+
ctx,
|
|
106
|
+
type: 'DateTimeMillis',
|
|
107
|
+
proto: luxon_2.DateTimeMillisUtcLuxon,
|
|
108
|
+
pattern: dateTimeMillisPattern,
|
|
109
|
+
parser: (value) => luxon_1.DateTime.fromISO(value, { zone: luxon_1.FixedOffsetZone.utcInstance }),
|
|
119
110
|
});
|
|
120
111
|
}
|
|
121
112
|
const durationPattern = /^P(?!$)(\d+(?:\.\d+)?Y)?(\d+(?:\.\d+)?M)?(\d+(?:\.\d+)?W)?(\d+(?:\.\d+)?D)?(T(?=\d)(\d+(?:\.\d+)?H)?(\d+(?:\.\d+)?M)?(\d+(?:\.\d+)?S)?)?$/;
|
package/dist/luxon.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DateTime, DateTimeJSOptions, DateTimeOptions } from 'luxon';
|
|
1
|
+
import { DateTime, DateTimeJSOptions, DateTimeOptions, Zone } from 'luxon';
|
|
2
2
|
export declare type LuxonDateTimeInput = DateTime | LuxonDateTime;
|
|
3
3
|
export declare abstract class LuxonDateTime {
|
|
4
4
|
readonly dateTime: DateTime;
|
|
@@ -19,8 +19,11 @@ export declare class LocalDateLuxon extends LuxonDateTime {
|
|
|
19
19
|
static nowLocal(options?: DateTimeJSOptions): LocalDateLuxon;
|
|
20
20
|
static nowUtc(): LocalDateLuxon;
|
|
21
21
|
static fromISO(value: string, options?: DateTimeOptions): LocalDateLuxon;
|
|
22
|
-
static
|
|
23
|
-
static
|
|
22
|
+
static fromFormat(value: string, format: string, options?: DateTimeOptions): LocalDateLuxon;
|
|
23
|
+
static fromJSDate(date: Date, options?: {
|
|
24
|
+
zone?: string | Zone;
|
|
25
|
+
}): LocalDateLuxon;
|
|
26
|
+
static fromMillis(millis: number, options?: DateTimeJSOptions): LocalDateLuxon;
|
|
24
27
|
protected normalize(dateTime: DateTime): DateTime;
|
|
25
28
|
wrap(fn: (dateTime: DateTime) => DateTime): LocalDateLuxon;
|
|
26
29
|
toJSON(): string;
|
|
@@ -31,8 +34,11 @@ export declare class LocalTimeLuxon extends LuxonDateTime {
|
|
|
31
34
|
static nowLocal(options?: DateTimeJSOptions): LocalTimeLuxon;
|
|
32
35
|
static nowUtc(): LocalTimeLuxon;
|
|
33
36
|
static fromISO(value: string, options?: DateTimeOptions): LocalTimeLuxon;
|
|
34
|
-
static
|
|
35
|
-
static
|
|
37
|
+
static fromFormat(value: string, format: string, options?: DateTimeOptions): LocalTimeLuxon;
|
|
38
|
+
static fromJSDate(date: Date, options?: {
|
|
39
|
+
zone?: string | Zone;
|
|
40
|
+
}): LocalTimeLuxon;
|
|
41
|
+
static fromMillis(millis: number, options?: DateTimeJSOptions): LocalTimeLuxon;
|
|
36
42
|
protected normalize(dateTime: DateTime): DateTime;
|
|
37
43
|
wrap(fn: (dateTime: DateTime) => DateTime): LocalTimeLuxon;
|
|
38
44
|
toJSON(): string;
|
|
@@ -43,8 +49,11 @@ export declare class DateTimeLuxon extends LuxonDateTime {
|
|
|
43
49
|
constructor(input: LuxonDateTimeInput);
|
|
44
50
|
static now(options?: DateTimeJSOptions): DateTimeLuxon;
|
|
45
51
|
static fromISO(value: string, options?: DateTimeOptions): DateTimeLuxon;
|
|
46
|
-
static
|
|
47
|
-
static
|
|
52
|
+
static fromFormat(value: string, format: string, options?: DateTimeOptions): DateTimeLuxon;
|
|
53
|
+
static fromJSDate(date: Date, options?: {
|
|
54
|
+
zone?: string | Zone;
|
|
55
|
+
}): DateTimeLuxon;
|
|
56
|
+
static fromMillis(millis: number, options?: DateTimeJSOptions): DateTimeLuxon;
|
|
48
57
|
protected normalize(dateTime: DateTime): DateTime;
|
|
49
58
|
wrap(fn: (dateTime: DateTime) => DateTime): DateTimeLuxon;
|
|
50
59
|
toJSON(): string;
|
|
@@ -53,8 +62,11 @@ export declare class DateTimeUtcLuxon extends LuxonDateTime {
|
|
|
53
62
|
constructor(input: LuxonDateTimeInput);
|
|
54
63
|
static now(): DateTimeUtcLuxon;
|
|
55
64
|
static fromISO(value: string, options?: DateTimeOptions): DateTimeUtcLuxon;
|
|
56
|
-
static
|
|
57
|
-
static
|
|
65
|
+
static fromFormat(value: string, format: string, options?: DateTimeOptions): DateTimeUtcLuxon;
|
|
66
|
+
static fromJSDate(date: Date, options?: {
|
|
67
|
+
zone?: string | Zone;
|
|
68
|
+
}): DateTimeUtcLuxon;
|
|
69
|
+
static fromMillis(millis: number, options?: DateTimeJSOptions): DateTimeUtcLuxon;
|
|
58
70
|
protected normalize(dateTime: DateTime): DateTime;
|
|
59
71
|
wrap(fn: (dateTime: DateTime) => DateTime): DateTimeUtcLuxon;
|
|
60
72
|
toJSON(): string;
|
|
@@ -65,8 +77,11 @@ export declare class DateTimeMillisLuxon extends LuxonDateTime {
|
|
|
65
77
|
constructor(input: LuxonDateTimeInput);
|
|
66
78
|
static now(options?: DateTimeJSOptions): DateTimeMillisLuxon;
|
|
67
79
|
static fromISO(value: string, options?: DateTimeOptions): DateTimeMillisLuxon;
|
|
68
|
-
static
|
|
69
|
-
static
|
|
80
|
+
static fromFormat(value: string, format: string, options?: DateTimeOptions): DateTimeMillisLuxon;
|
|
81
|
+
static fromJSDate(date: Date, options?: {
|
|
82
|
+
zone?: string | Zone;
|
|
83
|
+
}): DateTimeMillisLuxon;
|
|
84
|
+
static fromMillis(millis: number, options?: DateTimeJSOptions): DateTimeMillisLuxon;
|
|
70
85
|
protected normalize(dateTime: DateTime): DateTime;
|
|
71
86
|
wrap(fn: (dateTime: DateTime) => DateTime): DateTimeMillisLuxon;
|
|
72
87
|
toJSON(): string;
|
|
@@ -75,8 +90,11 @@ export declare class DateTimeMillisUtcLuxon extends LuxonDateTime {
|
|
|
75
90
|
constructor(input: LuxonDateTimeInput);
|
|
76
91
|
static now(): DateTimeMillisUtcLuxon;
|
|
77
92
|
static fromISO(value: string, options?: DateTimeOptions): DateTimeMillisUtcLuxon;
|
|
78
|
-
static
|
|
79
|
-
static
|
|
93
|
+
static fromFormat(value: string, format: string, options?: DateTimeOptions): DateTimeMillisUtcLuxon;
|
|
94
|
+
static fromJSDate(date: Date, options?: {
|
|
95
|
+
zone?: string | Zone;
|
|
96
|
+
}): DateTimeMillisUtcLuxon;
|
|
97
|
+
static fromMillis(millis: number, options?: DateTimeJSOptions): DateTimeMillisUtcLuxon;
|
|
80
98
|
protected normalize(dateTime: DateTime): DateTime;
|
|
81
99
|
wrap(fn: (dateTime: DateTime) => DateTime): DateTimeMillisUtcLuxon;
|
|
82
100
|
toJSON(): string;
|
package/dist/luxon.js
CHANGED
|
@@ -22,6 +22,9 @@ class LuxonDateTime {
|
|
|
22
22
|
return this.dateTime.valueOf();
|
|
23
23
|
}
|
|
24
24
|
as(type) {
|
|
25
|
+
if (this instanceof type) {
|
|
26
|
+
return this;
|
|
27
|
+
}
|
|
25
28
|
return new type(this.dateTime);
|
|
26
29
|
}
|
|
27
30
|
equals(other) {
|
|
@@ -43,13 +46,16 @@ class LocalDateLuxon extends LuxonDateTime {
|
|
|
43
46
|
return new LocalDateLuxon(luxon_1.DateTime.utc());
|
|
44
47
|
}
|
|
45
48
|
static fromISO(value, options) {
|
|
46
|
-
return new LocalDateLuxon(luxon_1.DateTime.fromISO(value, options));
|
|
49
|
+
return new LocalDateLuxon(luxon_1.DateTime.fromISO(value, Object.assign({ zone: luxon_1.FixedOffsetZone.utcInstance }, options)));
|
|
50
|
+
}
|
|
51
|
+
static fromFormat(value, format, options) {
|
|
52
|
+
return new LocalDateLuxon(luxon_1.DateTime.fromFormat(value, format, Object.assign({ zone: luxon_1.FixedOffsetZone.utcInstance }, options)));
|
|
47
53
|
}
|
|
48
54
|
static fromJSDate(date, options) {
|
|
49
|
-
return new LocalDateLuxon(luxon_1.DateTime.fromJSDate(date, options));
|
|
55
|
+
return new LocalDateLuxon(luxon_1.DateTime.fromJSDate(date, Object.assign({ zone: luxon_1.FixedOffsetZone.utcInstance }, options)));
|
|
50
56
|
}
|
|
51
57
|
static fromMillis(millis, options) {
|
|
52
|
-
return new LocalDateLuxon(luxon_1.DateTime.fromMillis(millis, options));
|
|
58
|
+
return new LocalDateLuxon(luxon_1.DateTime.fromMillis(millis, Object.assign({ zone: luxon_1.FixedOffsetZone.utcInstance }, options)));
|
|
53
59
|
}
|
|
54
60
|
normalize(dateTime) {
|
|
55
61
|
return luxon_1.DateTime.utc(dateTime.year, dateTime.month, dateTime.day);
|
|
@@ -74,13 +80,16 @@ class LocalTimeLuxon extends LuxonDateTime {
|
|
|
74
80
|
return new LocalTimeLuxon(luxon_1.DateTime.utc());
|
|
75
81
|
}
|
|
76
82
|
static fromISO(value, options) {
|
|
77
|
-
return new LocalTimeLuxon(luxon_1.DateTime.fromISO(value, options));
|
|
83
|
+
return new LocalTimeLuxon(luxon_1.DateTime.fromISO(value, Object.assign({ zone: luxon_1.FixedOffsetZone.utcInstance }, options)));
|
|
84
|
+
}
|
|
85
|
+
static fromFormat(value, format, options) {
|
|
86
|
+
return new LocalTimeLuxon(luxon_1.DateTime.fromFormat(value, format, Object.assign({ zone: luxon_1.FixedOffsetZone.utcInstance }, options)));
|
|
78
87
|
}
|
|
79
88
|
static fromJSDate(date, options) {
|
|
80
|
-
return new LocalTimeLuxon(luxon_1.DateTime.fromJSDate(date, options));
|
|
89
|
+
return new LocalTimeLuxon(luxon_1.DateTime.fromJSDate(date, Object.assign({ zone: luxon_1.FixedOffsetZone.utcInstance }, options)));
|
|
81
90
|
}
|
|
82
91
|
static fromMillis(millis, options) {
|
|
83
|
-
return new LocalTimeLuxon(luxon_1.DateTime.fromMillis(millis, options));
|
|
92
|
+
return new LocalTimeLuxon(luxon_1.DateTime.fromMillis(millis, Object.assign({ zone: luxon_1.FixedOffsetZone.utcInstance }, options)));
|
|
84
93
|
}
|
|
85
94
|
normalize(dateTime) {
|
|
86
95
|
return luxon_1.DateTime.utc(1970, 1, 1, dateTime.hour, dateTime.minute, dateTime.second);
|
|
@@ -104,6 +113,9 @@ class DateTimeLuxon extends LuxonDateTime {
|
|
|
104
113
|
static fromISO(value, options) {
|
|
105
114
|
return new DateTimeLuxon(luxon_1.DateTime.fromISO(value, Object.assign({ setZone: true }, options)));
|
|
106
115
|
}
|
|
116
|
+
static fromFormat(value, format, options) {
|
|
117
|
+
return new DateTimeLuxon(luxon_1.DateTime.fromFormat(value, format, Object.assign({ setZone: true }, options)));
|
|
118
|
+
}
|
|
107
119
|
static fromJSDate(date, options) {
|
|
108
120
|
return new DateTimeLuxon(luxon_1.DateTime.fromJSDate(date, options));
|
|
109
121
|
}
|
|
@@ -137,6 +149,9 @@ class DateTimeUtcLuxon extends LuxonDateTime {
|
|
|
137
149
|
static fromISO(value, options) {
|
|
138
150
|
return new DateTimeUtcLuxon(luxon_1.DateTime.fromISO(value, Object.assign({ zone: luxon_1.FixedOffsetZone.utcInstance }, options)));
|
|
139
151
|
}
|
|
152
|
+
static fromFormat(value, format, options) {
|
|
153
|
+
return new DateTimeUtcLuxon(luxon_1.DateTime.fromFormat(value, format, Object.assign({ zone: luxon_1.FixedOffsetZone.utcInstance }, options)));
|
|
154
|
+
}
|
|
140
155
|
static fromJSDate(date, options) {
|
|
141
156
|
return new DateTimeUtcLuxon(luxon_1.DateTime.fromJSDate(date, Object.assign({ zone: luxon_1.FixedOffsetZone.utcInstance }, options)));
|
|
142
157
|
}
|
|
@@ -164,6 +179,9 @@ class DateTimeMillisLuxon extends LuxonDateTime {
|
|
|
164
179
|
static fromISO(value, options) {
|
|
165
180
|
return new DateTimeMillisLuxon(luxon_1.DateTime.fromISO(value, Object.assign({ setZone: true }, options)));
|
|
166
181
|
}
|
|
182
|
+
static fromFormat(value, format, options) {
|
|
183
|
+
return new DateTimeMillisLuxon(luxon_1.DateTime.fromFormat(value, format, Object.assign({ setZone: true }, options)));
|
|
184
|
+
}
|
|
167
185
|
static fromJSDate(date, options) {
|
|
168
186
|
return new DateTimeMillisLuxon(luxon_1.DateTime.fromJSDate(date, options));
|
|
169
187
|
}
|
|
@@ -197,6 +215,9 @@ class DateTimeMillisUtcLuxon extends LuxonDateTime {
|
|
|
197
215
|
static fromISO(value, options) {
|
|
198
216
|
return new DateTimeMillisUtcLuxon(luxon_1.DateTime.fromISO(value, Object.assign({ zone: luxon_1.FixedOffsetZone.utcInstance }, options)));
|
|
199
217
|
}
|
|
218
|
+
static fromFormat(value, format, options) {
|
|
219
|
+
return new DateTimeMillisUtcLuxon(luxon_1.DateTime.fromFormat(value, format, Object.assign({ zone: luxon_1.FixedOffsetZone.utcInstance }, options)));
|
|
220
|
+
}
|
|
200
221
|
static fromJSDate(date, options) {
|
|
201
222
|
return new DateTimeMillisUtcLuxon(luxon_1.DateTime.fromJSDate(date, Object.assign({ zone: luxon_1.FixedOffsetZone.utcInstance }, options)));
|
|
202
223
|
}
|
package/dist/test-luxon.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const luxon_1 = require("luxon");
|
|
4
|
-
|
|
5
|
-
console.log(d === d.toUTC());
|
|
4
|
+
console.log(luxon_1.DateTime.fromFormat('2022-08-19+0', 'yyyy-MM-ddZ').toJSON());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@finnair/v-validation-luxon",
|
|
3
|
-
"version": "1.1.0-alpha.
|
|
3
|
+
"version": "1.1.0-alpha.9",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Luxon validators",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -32,5 +32,5 @@
|
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/luxon": "3.0.0"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "dcae3dd01e676de15d600898de5188c8384cb360"
|
|
36
36
|
}
|