@finnair/v-validation-luxon 1.1.0-alpha.4 → 1.1.0-alpha.5
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 +17 -0
- package/dist/Vluxon.d.ts +5 -5
- package/dist/Vluxon.js +15 -26
- package/dist/luxon.d.ts +30 -34
- package/dist/luxon.js +31 -49
- package/dist/test-luxon.js +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,23 @@
|
|
|
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.5](https://github.com/finnair/v-validation/compare/v1.0.1...v1.1.0-alpha.5) (2022-08-16)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* Fix exports ([904e63c](https://github.com/finnair/v-validation/commit/904e63c4a40e65d274349ae0f5ea80c697c5c8ce))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* fromISO helper for Luxon wrapper construction ([81d5b2e](https://github.com/finnair/v-validation/commit/81d5b2eb08f360ab56ec0c6caece392a0e6eb1a1))
|
|
17
|
+
* Support for Luxon ([6a243f0](https://github.com/finnair/v-validation/commit/6a243f043db2ca6700180eb758a08d8edfe1e538))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
6
23
|
# [1.1.0-alpha.4](https://github.com/finnair/v-validation/compare/v1.1.0-alpha.3...v1.1.0-alpha.4) (2022-08-15)
|
|
7
24
|
|
|
8
25
|
**Note:** Version bump only for package @finnair/v-validation-luxon
|
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 } from 'luxon';
|
|
3
|
+
import { DateTime, Zone } from 'luxon';
|
|
4
4
|
import { LuxonDateTime } from './luxon';
|
|
5
5
|
export declare type LuxonInput = string | DateTime | LuxonDateTime;
|
|
6
6
|
export interface ValidateLuxonParams {
|
|
@@ -10,18 +10,18 @@ export interface ValidateLuxonParams {
|
|
|
10
10
|
type: string;
|
|
11
11
|
proto: any;
|
|
12
12
|
pattern: RegExp;
|
|
13
|
+
defaultZone?: Zone;
|
|
13
14
|
}
|
|
14
|
-
export declare function validateLuxon({ value, path, ctx, type, proto, pattern }: ValidateLuxonParams): ValidationResult;
|
|
15
|
+
export declare function validateLuxon({ value, path, ctx, type, proto, pattern, defaultZone }: ValidateLuxonParams): ValidationResult;
|
|
15
16
|
export declare class DurationValidator extends Validator {
|
|
16
17
|
validatePath(value: any, path: Path, ctx: ValidationContext): Promise<ValidationResult>;
|
|
17
18
|
}
|
|
18
19
|
export declare const Vluxon: {
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
localDate: () => import("@finnair/v-validation").ValidatorFnWrapper;
|
|
21
|
+
localTime: () => import("@finnair/v-validation").ValidatorFnWrapper;
|
|
21
22
|
dateTime: () => import("@finnair/v-validation").ValidatorFnWrapper;
|
|
22
23
|
dateTimeUtc: () => import("@finnair/v-validation").ValidatorFnWrapper;
|
|
23
24
|
dateTimeMillis: () => import("@finnair/v-validation").ValidatorFnWrapper;
|
|
24
25
|
dateTimeMillisUtc: () => import("@finnair/v-validation").ValidatorFnWrapper;
|
|
25
|
-
time: () => import("@finnair/v-validation").ValidatorFnWrapper;
|
|
26
26
|
duration: () => DurationValidator;
|
|
27
27
|
};
|
package/dist/Vluxon.js
CHANGED
|
@@ -13,7 +13,7 @@ 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 }) {
|
|
16
|
+
function validateLuxon({ value, path, ctx, type, proto, pattern, defaultZone }) {
|
|
17
17
|
if ((0, v_validation_1.isNullOrUndefined)(value)) {
|
|
18
18
|
return ctx.failure(v_validation_1.defaultViolations.notNull(path), value);
|
|
19
19
|
}
|
|
@@ -27,7 +27,7 @@ function validateLuxon({ value, path, ctx, type, proto, pattern }) {
|
|
|
27
27
|
}
|
|
28
28
|
else if ((0, v_validation_1.isString)(value)) {
|
|
29
29
|
if (pattern.test(value)) {
|
|
30
|
-
const dateTime = luxon_1.DateTime.fromISO(value, { setZone: true });
|
|
30
|
+
const dateTime = luxon_1.DateTime.fromISO(value, { setZone: true, zone: defaultZone });
|
|
31
31
|
if (dateTime.isValid) {
|
|
32
32
|
return ctx.success(new proto(dateTime));
|
|
33
33
|
}
|
|
@@ -37,27 +37,30 @@ function validateLuxon({ value, path, ctx, type, proto, pattern }) {
|
|
|
37
37
|
}
|
|
38
38
|
exports.validateLuxon = validateLuxon;
|
|
39
39
|
const datePattern = /^\d{4}-\d{2}-\d{2}$/;
|
|
40
|
-
function
|
|
40
|
+
function localDateValidator(value, path, ctx) {
|
|
41
41
|
return __awaiter(this, void 0, void 0, function* () {
|
|
42
42
|
return validateLuxon({
|
|
43
43
|
value,
|
|
44
44
|
path,
|
|
45
45
|
ctx,
|
|
46
46
|
type: 'Date',
|
|
47
|
-
proto: luxon_2.
|
|
48
|
-
pattern: datePattern
|
|
47
|
+
proto: luxon_2.LocalDateLuxon,
|
|
48
|
+
pattern: datePattern,
|
|
49
|
+
defaultZone: luxon_1.FixedOffsetZone.utcInstance,
|
|
49
50
|
});
|
|
50
51
|
});
|
|
51
52
|
}
|
|
52
|
-
|
|
53
|
+
const timePattern = /^\d{2}:\d{2}:\d{2}$/;
|
|
54
|
+
function localTimeValidator(value, path, ctx) {
|
|
53
55
|
return __awaiter(this, void 0, void 0, function* () {
|
|
54
56
|
return validateLuxon({
|
|
55
57
|
value,
|
|
56
58
|
path,
|
|
57
59
|
ctx,
|
|
58
|
-
type: '
|
|
59
|
-
proto: luxon_2.
|
|
60
|
-
pattern:
|
|
60
|
+
type: 'Time',
|
|
61
|
+
proto: luxon_2.LocalTimeLuxon,
|
|
62
|
+
pattern: timePattern,
|
|
63
|
+
defaultZone: luxon_1.FixedOffsetZone.utcInstance,
|
|
61
64
|
});
|
|
62
65
|
});
|
|
63
66
|
}
|
|
@@ -70,7 +73,7 @@ function dateTimeValidator(value, path, ctx) {
|
|
|
70
73
|
ctx,
|
|
71
74
|
type: 'DateTime',
|
|
72
75
|
proto: luxon_2.DateTimeLuxon,
|
|
73
|
-
pattern: dateTimePattern
|
|
76
|
+
pattern: dateTimePattern,
|
|
74
77
|
});
|
|
75
78
|
});
|
|
76
79
|
}
|
|
@@ -111,19 +114,6 @@ function dateTimeMillisUtcValidator(value, path, ctx) {
|
|
|
111
114
|
});
|
|
112
115
|
});
|
|
113
116
|
}
|
|
114
|
-
const timePattern = /^\d{2}:\d{2}:\d{2}$/;
|
|
115
|
-
function timeValidator(value, path, ctx) {
|
|
116
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
117
|
-
return validateLuxon({
|
|
118
|
-
value,
|
|
119
|
-
path,
|
|
120
|
-
ctx,
|
|
121
|
-
type: 'Time',
|
|
122
|
-
proto: luxon_2.TimeLuxon,
|
|
123
|
-
pattern: timePattern
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
117
|
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)?)?$/;
|
|
128
118
|
class DurationValidator extends v_validation_1.Validator {
|
|
129
119
|
validatePath(value, path, ctx) {
|
|
@@ -146,12 +136,11 @@ class DurationValidator extends v_validation_1.Validator {
|
|
|
146
136
|
}
|
|
147
137
|
exports.DurationValidator = DurationValidator;
|
|
148
138
|
exports.Vluxon = {
|
|
149
|
-
|
|
150
|
-
|
|
139
|
+
localDate: () => v_validation_1.V.fn(localDateValidator),
|
|
140
|
+
localTime: () => v_validation_1.V.fn(localTimeValidator),
|
|
151
141
|
dateTime: () => v_validation_1.V.fn(dateTimeValidator),
|
|
152
142
|
dateTimeUtc: () => v_validation_1.V.fn(dateTimeUtcValidator),
|
|
153
143
|
dateTimeMillis: () => v_validation_1.V.fn(dateTimeMillisValidator),
|
|
154
144
|
dateTimeMillisUtc: () => v_validation_1.V.fn(dateTimeMillisUtcValidator),
|
|
155
|
-
time: () => v_validation_1.V.fn(timeValidator),
|
|
156
145
|
duration: () => new DurationValidator(),
|
|
157
146
|
};
|
package/dist/luxon.d.ts
CHANGED
|
@@ -1,34 +1,38 @@
|
|
|
1
|
-
import { DateTime } from 'luxon';
|
|
1
|
+
import { DateTime, DateTimeOptions } from 'luxon';
|
|
2
2
|
export declare type LuxonDateTimeInput = DateTime | LuxonDateTime;
|
|
3
3
|
export declare abstract class LuxonDateTime {
|
|
4
4
|
readonly dateTime: DateTime;
|
|
5
5
|
constructor(input: LuxonDateTimeInput);
|
|
6
|
-
protected normalize(dateTime: DateTime): DateTime;
|
|
6
|
+
protected abstract normalize(dateTime: DateTime): DateTime;
|
|
7
7
|
apply<R>(fn: (dateTime: DateTime) => R): R;
|
|
8
8
|
valueOf(): number;
|
|
9
|
+
as<T extends LuxonDateTime>(type: {
|
|
10
|
+
new (...args: any[]): T;
|
|
11
|
+
}): T;
|
|
9
12
|
equals(other: any): boolean;
|
|
10
13
|
abstract wrap(fn: (dateTime: DateTime) => DateTime): LuxonDateTime;
|
|
11
14
|
abstract toJSON(): string;
|
|
12
15
|
}
|
|
13
|
-
export declare class
|
|
16
|
+
export declare class LocalDateLuxon extends LuxonDateTime {
|
|
14
17
|
static readonly format = "yyyy-MM-dd";
|
|
15
18
|
constructor(input: LuxonDateTimeInput);
|
|
16
|
-
static now():
|
|
17
|
-
static fromISO(value: string, options?:
|
|
18
|
-
static fromJSDate(date: Date, options?:
|
|
19
|
-
static fromMillis(milliseconds: number, options?:
|
|
19
|
+
static now(): LocalDateLuxon;
|
|
20
|
+
static fromISO(value: string, options?: DateTimeOptions): LocalDateLuxon;
|
|
21
|
+
static fromJSDate(date: Date, options?: DateTimeOptions): LocalDateLuxon;
|
|
22
|
+
static fromMillis(milliseconds: number, options?: DateTimeOptions): LocalDateLuxon;
|
|
20
23
|
protected normalize(dateTime: DateTime): DateTime;
|
|
21
|
-
wrap(fn: (dateTime: DateTime) => DateTime):
|
|
24
|
+
wrap(fn: (dateTime: DateTime) => DateTime): LocalDateLuxon;
|
|
22
25
|
toJSON(): string;
|
|
23
26
|
}
|
|
24
|
-
export declare class
|
|
27
|
+
export declare class LocalTimeLuxon extends LuxonDateTime {
|
|
28
|
+
static readonly format = "HH:mm:ss";
|
|
25
29
|
constructor(input: LuxonDateTimeInput);
|
|
26
|
-
static now():
|
|
27
|
-
static fromISO(value: string, options?:
|
|
28
|
-
static fromJSDate(date: Date, options?:
|
|
29
|
-
static fromMillis(milliseconds: number, options?:
|
|
30
|
+
static now(): LocalTimeLuxon;
|
|
31
|
+
static fromISO(value: string, options?: DateTimeOptions): LocalTimeLuxon;
|
|
32
|
+
static fromJSDate(date: Date, options?: DateTimeOptions): LocalTimeLuxon;
|
|
33
|
+
static fromMillis(milliseconds: number, options?: DateTimeOptions): LocalTimeLuxon;
|
|
30
34
|
protected normalize(dateTime: DateTime): DateTime;
|
|
31
|
-
wrap(fn: (dateTime: DateTime) => DateTime):
|
|
35
|
+
wrap(fn: (dateTime: DateTime) => DateTime): LocalTimeLuxon;
|
|
32
36
|
toJSON(): string;
|
|
33
37
|
}
|
|
34
38
|
export declare class DateTimeLuxon extends LuxonDateTime {
|
|
@@ -36,9 +40,10 @@ export declare class DateTimeLuxon extends LuxonDateTime {
|
|
|
36
40
|
static readonly formatTz: string;
|
|
37
41
|
constructor(input: LuxonDateTimeInput);
|
|
38
42
|
static now(): DateTimeLuxon;
|
|
39
|
-
static fromISO(value: string, options?:
|
|
40
|
-
static fromJSDate(date: Date, options?:
|
|
41
|
-
static fromMillis(milliseconds: number, options?:
|
|
43
|
+
static fromISO(value: string, options?: DateTimeOptions): DateTimeLuxon;
|
|
44
|
+
static fromJSDate(date: Date, options?: DateTimeOptions): DateTimeLuxon;
|
|
45
|
+
static fromMillis(milliseconds: number, options?: DateTimeOptions): DateTimeLuxon;
|
|
46
|
+
protected normalize(dateTime: DateTime): DateTime;
|
|
42
47
|
wrap(fn: (dateTime: DateTime) => DateTime): DateTimeLuxon;
|
|
43
48
|
toJSON(): string;
|
|
44
49
|
}
|
|
@@ -46,8 +51,8 @@ export declare class DateTimeUtcLuxon extends LuxonDateTime {
|
|
|
46
51
|
constructor(input: LuxonDateTimeInput);
|
|
47
52
|
static now(): DateTimeUtcLuxon;
|
|
48
53
|
static fromISO(value: string): DateTimeUtcLuxon;
|
|
49
|
-
static fromJSDate(date: Date, options?:
|
|
50
|
-
static fromMillis(milliseconds: number, options?:
|
|
54
|
+
static fromJSDate(date: Date, options?: DateTimeOptions): DateTimeUtcLuxon;
|
|
55
|
+
static fromMillis(milliseconds: number, options?: DateTimeOptions): DateTimeUtcLuxon;
|
|
51
56
|
protected normalize(dateTime: DateTime): DateTime;
|
|
52
57
|
wrap(fn: (dateTime: DateTime) => DateTime): DateTimeUtcLuxon;
|
|
53
58
|
toJSON(): string;
|
|
@@ -58,28 +63,19 @@ export declare class DateTimeMillisLuxon extends LuxonDateTime {
|
|
|
58
63
|
constructor(input: LuxonDateTimeInput);
|
|
59
64
|
static now(): DateTimeMillisLuxon;
|
|
60
65
|
static fromISO(value: string): DateTimeMillisLuxon;
|
|
61
|
-
static fromJSDate(date: Date, options?:
|
|
62
|
-
static fromMillis(milliseconds: number, options?:
|
|
66
|
+
static fromJSDate(date: Date, options?: DateTimeOptions): DateTimeMillisLuxon;
|
|
67
|
+
static fromMillis(milliseconds: number, options?: DateTimeOptions): DateTimeMillisLuxon;
|
|
68
|
+
protected normalize(dateTime: DateTime): DateTime;
|
|
63
69
|
wrap(fn: (dateTime: DateTime) => DateTime): DateTimeMillisLuxon;
|
|
64
70
|
toJSON(): string;
|
|
65
71
|
}
|
|
66
72
|
export declare class DateTimeMillisUtcLuxon extends LuxonDateTime {
|
|
67
73
|
constructor(input: LuxonDateTimeInput);
|
|
68
74
|
static now(): DateTimeMillisUtcLuxon;
|
|
69
|
-
static fromISO(value: string, options?:
|
|
70
|
-
static fromJSDate(date: Date, options?:
|
|
71
|
-
static fromMillis(milliseconds: number, options?:
|
|
75
|
+
static fromISO(value: string, options?: DateTimeOptions): DateTimeMillisUtcLuxon;
|
|
76
|
+
static fromJSDate(date: Date, options?: DateTimeOptions): DateTimeMillisUtcLuxon;
|
|
77
|
+
static fromMillis(milliseconds: number, options?: DateTimeOptions): DateTimeMillisUtcLuxon;
|
|
72
78
|
protected normalize(dateTime: DateTime): DateTime;
|
|
73
79
|
wrap(fn: (dateTime: DateTime) => DateTime): DateTimeMillisUtcLuxon;
|
|
74
80
|
toJSON(): string;
|
|
75
81
|
}
|
|
76
|
-
export declare class TimeLuxon extends LuxonDateTime {
|
|
77
|
-
static readonly format = "HH:mm:ss";
|
|
78
|
-
constructor(input: LuxonDateTimeInput);
|
|
79
|
-
static now(): TimeLuxon;
|
|
80
|
-
static fromISO(value: string, options?: Object): TimeLuxon;
|
|
81
|
-
static fromJSDate(date: Date, options?: Object): TimeLuxon;
|
|
82
|
-
static fromMillis(milliseconds: number, options?: Object): TimeLuxon;
|
|
83
|
-
wrap(fn: (dateTime: DateTime) => DateTime): TimeLuxon;
|
|
84
|
-
toJSON(): string;
|
|
85
|
-
}
|
package/dist/luxon.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var _a, _b;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.
|
|
4
|
+
exports.DateTimeMillisUtcLuxon = exports.DateTimeMillisLuxon = exports.DateTimeUtcLuxon = exports.DateTimeLuxon = exports.LocalTimeLuxon = exports.LocalDateLuxon = exports.LuxonDateTime = void 0;
|
|
5
5
|
const luxon_1 = require("luxon");
|
|
6
6
|
class LuxonDateTime {
|
|
7
7
|
constructor(input) {
|
|
@@ -15,15 +15,15 @@ class LuxonDateTime {
|
|
|
15
15
|
this.dateTime = this.normalize(input);
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
-
normalize(dateTime) {
|
|
19
|
-
return dateTime;
|
|
20
|
-
}
|
|
21
18
|
apply(fn) {
|
|
22
19
|
return fn(this.dateTime);
|
|
23
20
|
}
|
|
24
21
|
valueOf() {
|
|
25
22
|
return this.dateTime.valueOf();
|
|
26
23
|
}
|
|
24
|
+
as(type) {
|
|
25
|
+
return new type(this.dateTime);
|
|
26
|
+
}
|
|
27
27
|
equals(other) {
|
|
28
28
|
if (this.constructor === other.constructor) {
|
|
29
29
|
return this.dateTime.equals(other.dateTime);
|
|
@@ -32,61 +32,62 @@ class LuxonDateTime {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
exports.LuxonDateTime = LuxonDateTime;
|
|
35
|
-
class
|
|
35
|
+
class LocalDateLuxon extends LuxonDateTime {
|
|
36
36
|
constructor(input) {
|
|
37
37
|
super(input);
|
|
38
38
|
}
|
|
39
39
|
static now() {
|
|
40
|
-
return new
|
|
40
|
+
return new LocalDateLuxon(luxon_1.DateTime.now());
|
|
41
41
|
}
|
|
42
42
|
static fromISO(value, options) {
|
|
43
|
-
return new
|
|
43
|
+
return new LocalDateLuxon(luxon_1.DateTime.fromISO(value, options));
|
|
44
44
|
}
|
|
45
45
|
static fromJSDate(date, options) {
|
|
46
|
-
return new
|
|
46
|
+
return new LocalDateLuxon(luxon_1.DateTime.fromJSDate(date, options));
|
|
47
47
|
}
|
|
48
48
|
static fromMillis(milliseconds, options) {
|
|
49
|
-
return new
|
|
49
|
+
return new LocalDateLuxon(luxon_1.DateTime.fromMillis(milliseconds, options));
|
|
50
50
|
}
|
|
51
51
|
normalize(dateTime) {
|
|
52
|
-
return dateTime.
|
|
52
|
+
return luxon_1.DateTime.utc(dateTime.year, dateTime.month, dateTime.day);
|
|
53
53
|
}
|
|
54
54
|
wrap(fn) {
|
|
55
|
-
return new
|
|
55
|
+
return new LocalDateLuxon(fn(this.dateTime));
|
|
56
56
|
}
|
|
57
57
|
toJSON() {
|
|
58
|
-
return this.dateTime.toFormat(
|
|
58
|
+
return this.dateTime.toFormat(LocalDateLuxon.format);
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
exports.
|
|
62
|
-
|
|
63
|
-
class
|
|
61
|
+
exports.LocalDateLuxon = LocalDateLuxon;
|
|
62
|
+
LocalDateLuxon.format = 'yyyy-MM-dd';
|
|
63
|
+
class LocalTimeLuxon extends LuxonDateTime {
|
|
64
64
|
constructor(input) {
|
|
65
65
|
super(input);
|
|
66
66
|
}
|
|
67
67
|
static now() {
|
|
68
|
-
return new
|
|
68
|
+
return new LocalTimeLuxon(luxon_1.DateTime.now());
|
|
69
69
|
}
|
|
70
70
|
static fromISO(value, options) {
|
|
71
|
-
return new
|
|
71
|
+
return new LocalTimeLuxon(luxon_1.DateTime.fromISO(value, options));
|
|
72
72
|
}
|
|
73
73
|
static fromJSDate(date, options) {
|
|
74
|
-
return new
|
|
74
|
+
return new LocalTimeLuxon(luxon_1.DateTime.fromJSDate(date, options));
|
|
75
75
|
}
|
|
76
76
|
static fromMillis(milliseconds, options) {
|
|
77
|
-
return new
|
|
77
|
+
return new LocalTimeLuxon(luxon_1.DateTime.fromMillis(milliseconds, options));
|
|
78
78
|
}
|
|
79
79
|
normalize(dateTime) {
|
|
80
|
-
return luxon_1.DateTime.utc(dateTime.
|
|
80
|
+
return luxon_1.DateTime.utc(1970, 1, 1, dateTime.hour, dateTime.minute, dateTime.second);
|
|
81
81
|
}
|
|
82
82
|
wrap(fn) {
|
|
83
|
-
return new
|
|
83
|
+
return new LocalTimeLuxon(fn(this.dateTime));
|
|
84
84
|
}
|
|
85
85
|
toJSON() {
|
|
86
|
-
return this.dateTime.toFormat(
|
|
86
|
+
return this.dateTime.toFormat(LocalTimeLuxon.format);
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
-
exports.
|
|
89
|
+
exports.LocalTimeLuxon = LocalTimeLuxon;
|
|
90
|
+
LocalTimeLuxon.format = 'HH:mm:ss';
|
|
90
91
|
class DateTimeLuxon extends LuxonDateTime {
|
|
91
92
|
constructor(input) {
|
|
92
93
|
super(input);
|
|
@@ -103,6 +104,9 @@ class DateTimeLuxon extends LuxonDateTime {
|
|
|
103
104
|
static fromMillis(milliseconds, options) {
|
|
104
105
|
return new DateTimeLuxon(luxon_1.DateTime.fromMillis(milliseconds, options));
|
|
105
106
|
}
|
|
107
|
+
normalize(dateTime) {
|
|
108
|
+
return dateTime.startOf('second');
|
|
109
|
+
}
|
|
106
110
|
wrap(fn) {
|
|
107
111
|
return new DateTimeLuxon(fn(this.dateTime));
|
|
108
112
|
}
|
|
@@ -134,7 +138,7 @@ class DateTimeUtcLuxon extends LuxonDateTime {
|
|
|
134
138
|
return new DateTimeUtcLuxon(luxon_1.DateTime.fromMillis(milliseconds, options));
|
|
135
139
|
}
|
|
136
140
|
normalize(dateTime) {
|
|
137
|
-
return dateTime.toUTC();
|
|
141
|
+
return dateTime.toUTC().startOf('second');
|
|
138
142
|
}
|
|
139
143
|
wrap(fn) {
|
|
140
144
|
return new DateTimeUtcLuxon(fn(this.dateTime));
|
|
@@ -160,6 +164,9 @@ class DateTimeMillisLuxon extends LuxonDateTime {
|
|
|
160
164
|
static fromMillis(milliseconds, options) {
|
|
161
165
|
return new DateTimeMillisLuxon(luxon_1.DateTime.fromMillis(milliseconds, options));
|
|
162
166
|
}
|
|
167
|
+
normalize(dateTime) {
|
|
168
|
+
return dateTime;
|
|
169
|
+
}
|
|
163
170
|
wrap(fn) {
|
|
164
171
|
return new DateTimeMillisLuxon(fn(this.dateTime));
|
|
165
172
|
}
|
|
@@ -201,28 +208,3 @@ class DateTimeMillisUtcLuxon extends LuxonDateTime {
|
|
|
201
208
|
}
|
|
202
209
|
}
|
|
203
210
|
exports.DateTimeMillisUtcLuxon = DateTimeMillisUtcLuxon;
|
|
204
|
-
class TimeLuxon extends LuxonDateTime {
|
|
205
|
-
constructor(input) {
|
|
206
|
-
super(input);
|
|
207
|
-
}
|
|
208
|
-
static now() {
|
|
209
|
-
return new TimeLuxon(luxon_1.DateTime.now());
|
|
210
|
-
}
|
|
211
|
-
static fromISO(value, options) {
|
|
212
|
-
return new TimeLuxon(luxon_1.DateTime.fromISO(value, options));
|
|
213
|
-
}
|
|
214
|
-
static fromJSDate(date, options) {
|
|
215
|
-
return new TimeLuxon(luxon_1.DateTime.fromJSDate(date, options));
|
|
216
|
-
}
|
|
217
|
-
static fromMillis(milliseconds, options) {
|
|
218
|
-
return new TimeLuxon(luxon_1.DateTime.fromMillis(milliseconds, options));
|
|
219
|
-
}
|
|
220
|
-
wrap(fn) {
|
|
221
|
-
return new TimeLuxon(fn(this.dateTime));
|
|
222
|
-
}
|
|
223
|
-
toJSON() {
|
|
224
|
-
return this.dateTime.toFormat(TimeLuxon.format);
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
exports.TimeLuxon = TimeLuxon;
|
|
228
|
-
TimeLuxon.format = 'HH:mm:ss';
|
package/dist/test-luxon.js
CHANGED
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.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Luxon validators",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -25,12 +25,12 @@
|
|
|
25
25
|
"build": "tsc -b ."
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@finnair/path": "^1.1.0-alpha.
|
|
29
|
-
"@finnair/v-validation": "^1.1.0-alpha.
|
|
28
|
+
"@finnair/path": "^1.1.0-alpha.5",
|
|
29
|
+
"@finnair/v-validation": "^1.1.0-alpha.5",
|
|
30
30
|
"luxon": "3.0.1"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/luxon": "3.0.0"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "593b0dc9cb646a7059d2ede95c44c3b80bec51d3"
|
|
36
36
|
}
|