@anglr/datetime 9.0.0-beta.20241007073342 → 9.0.0-beta.20241203113633
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 +10 -1
- package/es2022/src/pipes/dateConvert.pipe.js +4 -0
- package/es2022/src/pipes/dateConvert.pipe.js.map +1 -1
- package/es2022/src/pipes/dateFormat.pipe.js +5 -2
- package/es2022/src/pipes/dateFormat.pipe.js.map +1 -1
- package/package.json +1 -1
- package/src/pipes/dateConvert.pipe.d.ts +1 -1
- package/src/pipes/dateConvert.pipe.d.ts.map +1 -1
- package/src/pipes/dateFormat.pipe.d.ts +5 -5
- package/src/pipes/dateFormat.pipe.d.ts.map +1 -1
- package/version.bak +1 -1
package/changelog.md
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## Version 9.0.0 (2024-
|
|
3
|
+
## Version 9.0.0 (2024-12-03)
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
- fixed `DateConvertPipe` pipe
|
|
8
|
+
- fixed typings, now correctly accepts also `undefined` and `null`
|
|
9
|
+
- works as pre date-fns 4, which returns `null` value for `null` or `undefined` input value
|
|
10
|
+
- fixed `DateFormatPipe` pipe
|
|
11
|
+
- fixed typings, now correctly accepts also `undefined` and `null`
|
|
12
|
+
- works as pre date-fns 4, which returns empty string value for `null` or `undefined` input value
|
|
4
13
|
|
|
5
14
|
### Features
|
|
6
15
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Inject, Pipe } from '@angular/core';
|
|
2
|
+
import { isBlank } from '@jscrpt/common';
|
|
2
3
|
import { DATE_API } from '../misc/tokens';
|
|
3
4
|
import * as i0 from "@angular/core";
|
|
4
5
|
/**
|
|
@@ -16,6 +17,9 @@ export class DateConvertPipe {
|
|
|
16
17
|
* @param parseFormat - format used for parsing string date
|
|
17
18
|
*/
|
|
18
19
|
transform(value, parseFormat) {
|
|
20
|
+
if (isBlank(value)) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
19
23
|
const dateObj = this._dateApi.getValue(value, parseFormat);
|
|
20
24
|
if (dateObj.isValid()) {
|
|
21
25
|
return dateObj;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dateConvert.pipe.js","sourceRoot":"","sources":["../../../src/pipes/dateConvert.pipe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAE,IAAI,EAAgB,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"dateConvert.pipe.js","sourceRoot":"","sources":["../../../src/pipes/dateConvert.pipe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAE,IAAI,EAAgB,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAC,OAAO,EAAC,MAAM,gBAAgB,CAAC;AAEvC,OAAO,EAAC,QAAQ,EAAC,MAAM,gBAAgB,CAAC;;AAGxC;;GAEG;AAEH,MAAM,OAAO,eAAe;IAExB,kEAAkE;IAClE,YAAsC,QAAwB;QAAxB,aAAQ,GAAR,QAAQ,CAAgB;IAE9D,CAAC;IAED,sGAAsG;IAEtG;;;;OAIG;IACI,SAAS,CAAC,KAAqC,EAAE,WAAoB;QAExE,IAAG,OAAO,CAAC,KAAK,CAAC,EACjB,CAAC;YACG,OAAO,IAAI,CAAC;QAChB,CAAC;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;QAE3D,IAAG,OAAO,CAAC,OAAO,EAAE,EACpB,CAAC;YACG,OAAO,OAAO,CAAC;QACnB,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;8GA7BQ,eAAe,kBAGJ,QAAQ;4GAHnB,eAAe;;2FAAf,eAAe;kBAD3B,IAAI;mBAAC,EAAC,IAAI,EAAE,aAAa,EAAE,UAAU,EAAE,IAAI,EAAC;;0BAI5B,MAAM;2BAAC,QAAQ","sourcesContent":["import {Inject, Pipe, PipeTransform} from '@angular/core';\nimport {isBlank} from '@jscrpt/common';\n\nimport {DATE_API} from '../misc/tokens';\nimport {DateApi, DateApiObject, DateValue} from '../services';\n\n/**\n * Pipe that is used for converting date\n */\n@Pipe({name: 'dateConvert', standalone: true})\nexport class DateConvertPipe<TDate = unknown> implements PipeTransform\n{\n //######################### constructors #########################\n constructor(@Inject(DATE_API) private _dateApi: DateApi<TDate>)\n {\n }\n\n //######################### public methods - implementation of PipeTransform #########################\n\n /**\n * Transforms value into date object\n * @param value - value to be transformed\n * @param parseFormat - format used for parsing string date\n */\n public transform(value: TDate|DateValue|undefined|null, parseFormat?: string): DateApiObject<TDate>|null\n {\n if(isBlank(value))\n {\n return null;\n }\n\n const dateObj = this._dateApi.getValue(value, parseFormat);\n\n if(dateObj.isValid())\n {\n return dateObj;\n }\n\n return null;\n }\n}"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Inject, Pipe } from '@angular/core';
|
|
2
|
-
import { isString, nameof } from '@jscrpt/common';
|
|
2
|
+
import { isBlank, isString, nameof } from '@jscrpt/common';
|
|
3
3
|
import { DATE_API, FORMAT_PROVIDER } from '../misc/tokens';
|
|
4
4
|
import * as i0 from "@angular/core";
|
|
5
5
|
/**
|
|
@@ -12,10 +12,13 @@ export class DateFormatPipe {
|
|
|
12
12
|
this._dateApi = _dateApi;
|
|
13
13
|
}
|
|
14
14
|
transform(value, format = nameof('date'), parseFormatOrCustomFormat, _customFormat) {
|
|
15
|
+
if (isBlank(value)) {
|
|
16
|
+
return '';
|
|
17
|
+
}
|
|
15
18
|
const parseFormat = isString(parseFormatOrCustomFormat) ? parseFormatOrCustomFormat : undefined;
|
|
16
19
|
//format provider value
|
|
17
20
|
if (format in this._formatProvider) {
|
|
18
|
-
format = this._formatProvider[format];
|
|
21
|
+
format = (this._formatProvider)[format];
|
|
19
22
|
}
|
|
20
23
|
const dateObj = this._dateApi.getValue(value, parseFormat);
|
|
21
24
|
if (dateObj.isValid()) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dateFormat.pipe.js","sourceRoot":"","sources":["../../../src/pipes/dateFormat.pipe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAE,IAAI,EAAgB,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAC,QAAQ,EAAE,MAAM,EAAC,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"dateFormat.pipe.js","sourceRoot":"","sources":["../../../src/pipes/dateFormat.pipe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAE,IAAI,EAAgB,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAC,MAAM,gBAAgB,CAAC;AAGzD,OAAO,EAAC,QAAQ,EAAE,eAAe,EAAC,MAAM,gBAAgB,CAAC;;AAGzD;;GAEG;AAEH,MAAM,OAAO,cAAc;IAEvB,kEAAkE;IAClE,YAA6C,eAA+B,EACtC,QAAwB;QADjB,oBAAe,GAAf,eAAe,CAAgB;QACtC,aAAQ,GAAR,QAAQ,CAAgB;IAE9D,CAAC;IAqCM,SAAS,CAAC,KAAqC,EAAE,SAAsC,MAAM,CAAiB,MAAM,CAAC,EAAE,yBAA0C,EAAE,aAAuB;QAE7L,IAAG,OAAO,CAAC,KAAK,CAAC,EACjB,CAAC;YACG,OAAO,EAAE,CAAC;QACd,CAAC;QAED,MAAM,WAAW,GAAqB,QAAQ,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,SAAS,CAAC;QAElH,uBAAuB;QACvB,IAAG,MAAM,IAAI,IAAI,CAAC,eAAe,EACjC,CAAC;YACG,MAAM,GAAG,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,MAA8B,CAAC,CAAC;QACpE,CAAC;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;QAE3D,IAAG,OAAO,CAAC,OAAO,EAAE,EACpB,CAAC;YACG,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;QAC3D,CAAC;QAED,OAAO,EAAE,CAAC;IACd,CAAC;8GAlEQ,cAAc,kBAGH,eAAe,aACf,QAAQ;4GAJnB,cAAc;;2FAAd,cAAc;kBAD1B,IAAI;mBAAC,EAAC,IAAI,EAAE,YAAY,EAAE,UAAU,EAAE,IAAI,EAAC;;0BAI3B,MAAM;2BAAC,eAAe;;0BACtB,MAAM;2BAAC,QAAQ","sourcesContent":["import {Inject, Pipe, PipeTransform} from '@angular/core';\nimport {isBlank, isString, nameof} from '@jscrpt/common';\n\nimport {FormatProvider} from '../interfaces';\nimport {DATE_API, FORMAT_PROVIDER} from '../misc/tokens';\nimport {DateApi, DateValue} from '../services';\n\n/**\n * Pipe that is used for formatting date\n */\n@Pipe({name: 'dateFormat', standalone: true})\nexport class DateFormatPipe<TDate = unknown> implements PipeTransform\n{\n //######################### constructors #########################\n constructor(@Inject(FORMAT_PROVIDER) private _formatProvider: FormatProvider,\n @Inject(DATE_API) private _dateApi: DateApi<TDate>)\n {\n }\n\n //######################### public methods - implementation of PipeTransform #########################\n\n /**\n * Formats provided date into formatted string, with default format 'date'\n * @param value - value to be transformed\n */\n public transform(value: TDate|DateValue|undefined|null): string\n /**\n * Formats provided date into formatted string\n * @param value - value to be transformed\n * @param format - predefined format that is used for formatting, one of 'FormatProvider' keys\n */\n public transform(value: TDate|DateValue|undefined|null, format: keyof FormatProvider): string\n /**\n * Formats provided date into formatted string\n * @param value - value to be transformed\n * @param format - predefined format that is used for formatting, one of 'FormatProvider' keys\n * @param parseFormat - format used for parsing string date\n */\n public transform(value: TDate|DateValue|undefined|null, format: keyof FormatProvider, parseFormat: string): string\n /**\n * Formats provided date into formatted string\n * @param value - value to be transformed\n * @param format - format that is used for formatting\n * @param customFormat - indication that custom format is used\n */\n public transform(value: TDate|DateValue|undefined|null, format: string, customFormat: true): string\n /**\n * Formats provided date into formatted string\n * @param value - value to be transformed\n * @param format - format that is used for formatting\n * @param parseFormat - format used for parsing string date\n * @param customFormat - indication that custom format is used\n */\n public transform(value: TDate|DateValue|undefined|null, format: string, parseFormat: string, customFormat: true): string\n public transform(value: TDate|DateValue|undefined|null, format: string|keyof FormatProvider = nameof<FormatProvider>('date'), parseFormatOrCustomFormat?: string|boolean, _customFormat?: boolean): string\n {\n if(isBlank(value))\n {\n return '';\n }\n\n const parseFormat: string|undefined = isString(parseFormatOrCustomFormat) ? parseFormatOrCustomFormat : undefined;\n \n //format provider value\n if(format in this._formatProvider)\n {\n format = (this._formatProvider)[format as keyof FormatProvider];\n }\n\n const dateObj = this._dateApi.getValue(value, parseFormat);\n\n if(dateObj.isValid())\n {\n return dateObj.format(this._dateApi.getFormat(format));\n }\n\n return '';\n }\n}"]}
|
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@ export declare class DateConvertPipe<TDate = unknown> implements PipeTransform {
|
|
|
12
12
|
* @param value - value to be transformed
|
|
13
13
|
* @param parseFormat - format used for parsing string date
|
|
14
14
|
*/
|
|
15
|
-
transform(value: TDate | DateValue, parseFormat?: string): DateApiObject<TDate> | null;
|
|
15
|
+
transform(value: TDate | DateValue | undefined | null, parseFormat?: string): DateApiObject<TDate> | null;
|
|
16
16
|
static ɵfac: i0.ɵɵFactoryDeclaration<DateConvertPipe<any>, never>;
|
|
17
17
|
static ɵpipe: i0.ɵɵPipeDeclaration<DateConvertPipe<any>, "dateConvert", true>;
|
|
18
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dateConvert.pipe.d.ts","sourceRoot":"","sources":["dateConvert.pipe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,aAAa,EAAC,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"dateConvert.pipe.d.ts","sourceRoot":"","sources":["dateConvert.pipe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,aAAa,EAAC,MAAM,eAAe,CAAC;AAI1D,OAAO,EAAC,OAAO,EAAE,aAAa,EAAE,SAAS,EAAC,MAAM,aAAa,CAAC;;AAE9D;;GAEG;AACH,qBACa,eAAe,CAAC,KAAK,GAAG,OAAO,CAAE,YAAW,aAAa;IAGpC,OAAO,CAAC,QAAQ;gBAAR,QAAQ,EAAE,OAAO,CAAC,KAAK,CAAC;IAM9D;;;;OAIG;IACI,SAAS,CAAC,KAAK,EAAE,KAAK,GAAC,SAAS,GAAC,SAAS,GAAC,IAAI,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,aAAa,CAAC,KAAK,CAAC,GAAC,IAAI;yCAd/F,eAAe;uCAAf,eAAe;CA8B3B"}
|
|
@@ -13,27 +13,27 @@ export declare class DateFormatPipe<TDate = unknown> implements PipeTransform {
|
|
|
13
13
|
* Formats provided date into formatted string, with default format 'date'
|
|
14
14
|
* @param value - value to be transformed
|
|
15
15
|
*/
|
|
16
|
-
transform(value: TDate | DateValue): string;
|
|
16
|
+
transform(value: TDate | DateValue | undefined | null): string;
|
|
17
17
|
/**
|
|
18
18
|
* Formats provided date into formatted string
|
|
19
19
|
* @param value - value to be transformed
|
|
20
20
|
* @param format - predefined format that is used for formatting, one of 'FormatProvider' keys
|
|
21
21
|
*/
|
|
22
|
-
transform(value: TDate | DateValue, format: keyof FormatProvider): string;
|
|
22
|
+
transform(value: TDate | DateValue | undefined | null, format: keyof FormatProvider): string;
|
|
23
23
|
/**
|
|
24
24
|
* Formats provided date into formatted string
|
|
25
25
|
* @param value - value to be transformed
|
|
26
26
|
* @param format - predefined format that is used for formatting, one of 'FormatProvider' keys
|
|
27
27
|
* @param parseFormat - format used for parsing string date
|
|
28
28
|
*/
|
|
29
|
-
transform(value: TDate | DateValue, format: keyof FormatProvider, parseFormat: string): string;
|
|
29
|
+
transform(value: TDate | DateValue | undefined | null, format: keyof FormatProvider, parseFormat: string): string;
|
|
30
30
|
/**
|
|
31
31
|
* Formats provided date into formatted string
|
|
32
32
|
* @param value - value to be transformed
|
|
33
33
|
* @param format - format that is used for formatting
|
|
34
34
|
* @param customFormat - indication that custom format is used
|
|
35
35
|
*/
|
|
36
|
-
transform(value: TDate | DateValue, format: string, customFormat: true): string;
|
|
36
|
+
transform(value: TDate | DateValue | undefined | null, format: string, customFormat: true): string;
|
|
37
37
|
/**
|
|
38
38
|
* Formats provided date into formatted string
|
|
39
39
|
* @param value - value to be transformed
|
|
@@ -41,7 +41,7 @@ export declare class DateFormatPipe<TDate = unknown> implements PipeTransform {
|
|
|
41
41
|
* @param parseFormat - format used for parsing string date
|
|
42
42
|
* @param customFormat - indication that custom format is used
|
|
43
43
|
*/
|
|
44
|
-
transform(value: TDate | DateValue, format: string, parseFormat: string, customFormat: true): string;
|
|
44
|
+
transform(value: TDate | DateValue | undefined | null, format: string, parseFormat: string, customFormat: true): string;
|
|
45
45
|
static ɵfac: i0.ɵɵFactoryDeclaration<DateFormatPipe<any>, never>;
|
|
46
46
|
static ɵpipe: i0.ɵɵPipeDeclaration<DateFormatPipe<any>, "dateFormat", true>;
|
|
47
47
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dateFormat.pipe.d.ts","sourceRoot":"","sources":["dateFormat.pipe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,aAAa,EAAC,MAAM,eAAe,CAAC;AAG1D,OAAO,EAAC,cAAc,EAAC,MAAM,eAAe,CAAC;AAE7C,OAAO,EAAC,OAAO,EAAE,SAAS,EAAC,MAAM,aAAa,CAAC;;AAE/C;;GAEG;AACH,qBACa,cAAc,CAAC,KAAK,GAAG,OAAO,CAAE,YAAW,aAAa;IAG5B,OAAO,CAAC,eAAe;IAC9B,OAAO,CAAC,QAAQ;gBADD,eAAe,EAAE,cAAc,EACtC,QAAQ,EAAE,OAAO,CAAC,KAAK,CAAC;IAM9D;;;OAGG;I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