@libs-ui/pipes-format-date 0.2.51 → 0.2.52
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.
|
@@ -1,94 +1,10 @@
|
|
|
1
|
-
import { Pipe } from '@angular/core';
|
|
2
|
-
import {
|
|
3
|
-
import * as dayjs from 'dayjs';
|
|
4
|
-
import * as en from 'dayjs/locale/en';
|
|
5
|
-
import * as vi from 'dayjs/locale/vi';
|
|
6
|
-
import * as updateLocale from 'dayjs/plugin/updateLocale';
|
|
1
|
+
import { Pipe, inject } from '@angular/core';
|
|
2
|
+
import { FormatDateService } from '@libs-ui/services-format-date';
|
|
7
3
|
import * as i0 from "@angular/core";
|
|
8
|
-
dayjs.extend(updateLocale);
|
|
9
4
|
export class LibsUiPipesFormatDatePipe {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return '';
|
|
14
|
-
}
|
|
15
|
-
console.log('lang', lang);
|
|
16
|
-
lang = lang || UtilsCache.getLang();
|
|
17
|
-
if (functionCustomFormat) {
|
|
18
|
-
return functionCustomFormat(time, format, lang);
|
|
19
|
-
}
|
|
20
|
-
console.log('format', format);
|
|
21
|
-
// if (formatDate()) {
|
|
22
|
-
// return formatDate()?.(time, format, lang) || '';
|
|
23
|
-
// }
|
|
24
|
-
time = typeof time === 'number' ? dayjs.unix(time).locale(lang) : dayjs(time).locale(lang);
|
|
25
|
-
this.updateLocale(lang);
|
|
26
|
-
console.log('1');
|
|
27
|
-
if (typeof time === 'number') {
|
|
28
|
-
return dayjs.unix(time).format(this.getFormatData(this.getTypeByFormat(format), lang));
|
|
29
|
-
}
|
|
30
|
-
console.log('2');
|
|
31
|
-
return dayjs(time).format(this.getFormatData(this.getTypeByFormat(format), lang));
|
|
32
|
-
}
|
|
33
|
-
updateLocale(lang) {
|
|
34
|
-
if (lang === 'vi') {
|
|
35
|
-
dayjs.locale(vi);
|
|
36
|
-
dayjs.updateLocale('vi', {
|
|
37
|
-
monthsShort: 'Thg 1_Thg 2_Thg 3_Thg 4_Thg 5_Thg 6_Thg 7_Thg 8_Thg 9_Thg 10_Thg 11_Thg 12'.split('_')
|
|
38
|
-
});
|
|
39
|
-
console.log('3', lang);
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
console.log('4');
|
|
43
|
-
dayjs.locale(en);
|
|
44
|
-
}
|
|
45
|
-
getTypeByFormat(format) {
|
|
46
|
-
console.log('5');
|
|
47
|
-
if (format === 'dm' || format === 'dmy' || format === 'dmy hm' || format === 'my') {
|
|
48
|
-
return format;
|
|
49
|
-
}
|
|
50
|
-
if (format === 'DD/MM/YYYY' || format === 'YYYY-MM-DD' || format === 'dd/MM/yyyy' || format === 'dd-MM-yyyy' || format === 'dd/mm/yyyy') {
|
|
51
|
-
return 'dmy';
|
|
52
|
-
}
|
|
53
|
-
if (format === 'MM-DD' || format === 'dd/MM' || format === 'dd/mm') {
|
|
54
|
-
return 'dm';
|
|
55
|
-
}
|
|
56
|
-
if (format === 'M/YYYY' || format === 'YYYY-MM' || format === 'MM/yyyy') {
|
|
57
|
-
return 'my';
|
|
58
|
-
}
|
|
59
|
-
if (format === 'YYYY/MM/DD hh:mm:ss' || format === 'dmy hms' || format === 'dd/mm/yyyy hh:mm:ss') {
|
|
60
|
-
return 'dmy hms';
|
|
61
|
-
}
|
|
62
|
-
return 'dmy hm';
|
|
63
|
-
}
|
|
64
|
-
getFormatData(type, lang) {
|
|
65
|
-
switch (type) {
|
|
66
|
-
case 'dm':
|
|
67
|
-
if (lang === 'vi') {
|
|
68
|
-
return 'D MMM';
|
|
69
|
-
}
|
|
70
|
-
return 'MMM D';
|
|
71
|
-
case 'dmy':
|
|
72
|
-
if (lang === 'vi') {
|
|
73
|
-
return 'D MMM, YYYY';
|
|
74
|
-
}
|
|
75
|
-
return 'MMM D, YYYY';
|
|
76
|
-
case 'dmy hm':
|
|
77
|
-
if (lang === 'vi') {
|
|
78
|
-
return 'D MMM, YYYY HH:mm';
|
|
79
|
-
}
|
|
80
|
-
return 'MMM D, YYYY HH:mm';
|
|
81
|
-
case 'my':
|
|
82
|
-
if (lang === 'vi') {
|
|
83
|
-
return 'MMM, YYYY';
|
|
84
|
-
}
|
|
85
|
-
return 'MMM YYYY ';
|
|
86
|
-
case 'dmy hms':
|
|
87
|
-
if (lang === 'vi') {
|
|
88
|
-
return 'D MMM, YYYY HH:mm:ss';
|
|
89
|
-
}
|
|
90
|
-
return 'MMM D, YYYY HH:mm:ss';
|
|
91
|
-
}
|
|
5
|
+
formatDate = inject(FormatDateService);
|
|
6
|
+
transform(time, format = 'YYYY/MM/DD HH:mm', lang) {
|
|
7
|
+
return this.formatDate.transform(time, format, lang);
|
|
92
8
|
}
|
|
93
9
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: LibsUiPipesFormatDatePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
94
10
|
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "18.2.13", ngImport: i0, type: LibsUiPipesFormatDatePipe, isStandalone: true, name: "LibsUiPipesFormatDatePipe" });
|
|
@@ -100,4 +16,4 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
|
|
|
100
16
|
standalone: true
|
|
101
17
|
}]
|
|
102
18
|
}] });
|
|
103
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
19
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZm9ybWF0LWRhdGUucGlwZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL2xpYnMtdWkvcGlwZXMvZm9ybWF0LWRhdGUvc3JjL2Zvcm1hdC1kYXRlLnBpcGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLElBQUksRUFBaUIsTUFBTSxFQU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LkRheWpzIHwgdW5kZWZpbmVkIHwgbnVsbCwgZm9ybWF0ID0gJ1lZWVkvTU0vREQgSEg6bW0nLCBsYW5nPzogc3RyaW5nKTogc3RyaW5nIHtcbiAgICByZXR1cm4gdGhpcy5mb3JtYXREYXRlLnRyYW5zZm9ybSh0aW1lLCBmb3JtYXQsIGxhbmcpO1xuICB9XG59XG4iXX0=
|
|
@@ -1,95 +1,11 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { Pipe } from '@angular/core';
|
|
3
|
-
import {
|
|
4
|
-
import * as dayjs from 'dayjs';
|
|
5
|
-
import * as en from 'dayjs/locale/en';
|
|
6
|
-
import * as vi from 'dayjs/locale/vi';
|
|
7
|
-
import * as updateLocale from 'dayjs/plugin/updateLocale';
|
|
2
|
+
import { inject, Pipe } from '@angular/core';
|
|
3
|
+
import { FormatDateService } from '@libs-ui/services-format-date';
|
|
8
4
|
|
|
9
|
-
dayjs.extend(updateLocale);
|
|
10
5
|
class LibsUiPipesFormatDatePipe {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return '';
|
|
15
|
-
}
|
|
16
|
-
console.log('lang', lang);
|
|
17
|
-
lang = lang || UtilsCache.getLang();
|
|
18
|
-
if (functionCustomFormat) {
|
|
19
|
-
return functionCustomFormat(time, format, lang);
|
|
20
|
-
}
|
|
21
|
-
console.log('format', format);
|
|
22
|
-
// if (formatDate()) {
|
|
23
|
-
// return formatDate()?.(time, format, lang) || '';
|
|
24
|
-
// }
|
|
25
|
-
time = typeof time === 'number' ? dayjs.unix(time).locale(lang) : dayjs(time).locale(lang);
|
|
26
|
-
this.updateLocale(lang);
|
|
27
|
-
console.log('1');
|
|
28
|
-
if (typeof time === 'number') {
|
|
29
|
-
return dayjs.unix(time).format(this.getFormatData(this.getTypeByFormat(format), lang));
|
|
30
|
-
}
|
|
31
|
-
console.log('2');
|
|
32
|
-
return dayjs(time).format(this.getFormatData(this.getTypeByFormat(format), lang));
|
|
33
|
-
}
|
|
34
|
-
updateLocale(lang) {
|
|
35
|
-
if (lang === 'vi') {
|
|
36
|
-
dayjs.locale(vi);
|
|
37
|
-
dayjs.updateLocale('vi', {
|
|
38
|
-
monthsShort: 'Thg 1_Thg 2_Thg 3_Thg 4_Thg 5_Thg 6_Thg 7_Thg 8_Thg 9_Thg 10_Thg 11_Thg 12'.split('_')
|
|
39
|
-
});
|
|
40
|
-
console.log('3', lang);
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
console.log('4');
|
|
44
|
-
dayjs.locale(en);
|
|
45
|
-
}
|
|
46
|
-
getTypeByFormat(format) {
|
|
47
|
-
console.log('5');
|
|
48
|
-
if (format === 'dm' || format === 'dmy' || format === 'dmy hm' || format === 'my') {
|
|
49
|
-
return format;
|
|
50
|
-
}
|
|
51
|
-
if (format === 'DD/MM/YYYY' || format === 'YYYY-MM-DD' || format === 'dd/MM/yyyy' || format === 'dd-MM-yyyy' || format === 'dd/mm/yyyy') {
|
|
52
|
-
return 'dmy';
|
|
53
|
-
}
|
|
54
|
-
if (format === 'MM-DD' || format === 'dd/MM' || format === 'dd/mm') {
|
|
55
|
-
return 'dm';
|
|
56
|
-
}
|
|
57
|
-
if (format === 'M/YYYY' || format === 'YYYY-MM' || format === 'MM/yyyy') {
|
|
58
|
-
return 'my';
|
|
59
|
-
}
|
|
60
|
-
if (format === 'YYYY/MM/DD hh:mm:ss' || format === 'dmy hms' || format === 'dd/mm/yyyy hh:mm:ss') {
|
|
61
|
-
return 'dmy hms';
|
|
62
|
-
}
|
|
63
|
-
return 'dmy hm';
|
|
64
|
-
}
|
|
65
|
-
getFormatData(type, lang) {
|
|
66
|
-
switch (type) {
|
|
67
|
-
case 'dm':
|
|
68
|
-
if (lang === 'vi') {
|
|
69
|
-
return 'D MMM';
|
|
70
|
-
}
|
|
71
|
-
return 'MMM D';
|
|
72
|
-
case 'dmy':
|
|
73
|
-
if (lang === 'vi') {
|
|
74
|
-
return 'D MMM, YYYY';
|
|
75
|
-
}
|
|
76
|
-
return 'MMM D, YYYY';
|
|
77
|
-
case 'dmy hm':
|
|
78
|
-
if (lang === 'vi') {
|
|
79
|
-
return 'D MMM, YYYY HH:mm';
|
|
80
|
-
}
|
|
81
|
-
return 'MMM D, YYYY HH:mm';
|
|
82
|
-
case 'my':
|
|
83
|
-
if (lang === 'vi') {
|
|
84
|
-
return 'MMM, YYYY';
|
|
85
|
-
}
|
|
86
|
-
return 'MMM YYYY ';
|
|
87
|
-
case 'dmy hms':
|
|
88
|
-
if (lang === 'vi') {
|
|
89
|
-
return 'D MMM, YYYY HH:mm:ss';
|
|
90
|
-
}
|
|
91
|
-
return 'MMM D, YYYY HH:mm:ss';
|
|
92
|
-
}
|
|
6
|
+
formatDate = inject(FormatDateService);
|
|
7
|
+
transform(time, format = 'YYYY/MM/DD HH:mm', lang) {
|
|
8
|
+
return this.formatDate.transform(time, format, lang);
|
|
93
9
|
}
|
|
94
10
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: LibsUiPipesFormatDatePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
95
11
|
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "18.2.13", ngImport: i0, type: LibsUiPipesFormatDatePipe, isStandalone: true, name: "LibsUiPipesFormatDatePipe" });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"libs-ui-pipes-format-date.mjs","sources":["../../../../../libs-ui/pipes/format-date/src/format-date.pipe.ts","../../../../../libs-ui/pipes/format-date/src/libs-ui-pipes-format-date.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"libs-ui-pipes-format-date.mjs","sources":["../../../../../libs-ui/pipes/format-date/src/format-date.pipe.ts","../../../../../libs-ui/pipes/format-date/src/libs-ui-pipes-format-date.ts"],"sourcesContent":["import { Pipe, PipeTransform, inject } from '@angular/core';\nimport * as dayjs from 'dayjs';\nimport { FormatDateService } from '@libs-ui/services-format-date';\n\n@Pipe({\n name: 'LibsUiPipesFormatDatePipe',\n standalone: true\n})\nexport class LibsUiPipesFormatDatePipe implements PipeTransform {\n private formatDate = inject(FormatDateService);\n\n transform(time: string | number | dayjs.Dayjs | undefined | null, format = 'YYYY/MM/DD HH:mm', lang?: string): string {\n return this.formatDate.transform(time, format, lang);\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;MAQa,yBAAyB,CAAA;AAC5B,IAAA,UAAU,GAAG,MAAM,CAAC,iBAAiB,CAAC;AAE9C,IAAA,SAAS,CAAC,IAAsD,EAAE,MAAM,GAAG,kBAAkB,EAAE,IAAa,EAAA;AAC1G,QAAA,OAAO,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC;;wGAJ3C,yBAAyB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,IAAA,EAAA,CAAA;sGAAzB,yBAAyB,EAAA,YAAA,EAAA,IAAA,EAAA,IAAA,EAAA,2BAAA,EAAA,CAAA;;4FAAzB,yBAAyB,EAAA,UAAA,EAAA,CAAA;kBAJrC,IAAI;AAAC,YAAA,IAAA,EAAA,CAAA;AACJ,oBAAA,IAAI,EAAE,2BAA2B;AACjC,oBAAA,UAAU,EAAE;AACb,iBAAA;;;ACPD;;AAEG;;;;"}
|
package/format-date.pipe.d.ts
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { PipeTransform } from '@angular/core';
|
|
2
|
-
import { TYPE_FUNCTION_FORMAT_DATE } from '@libs-ui/utils';
|
|
3
2
|
import * as dayjs from 'dayjs';
|
|
4
3
|
import * as i0 from "@angular/core";
|
|
5
4
|
export declare class LibsUiPipesFormatDatePipe implements PipeTransform {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
private getTypeByFormat;
|
|
9
|
-
private getFormatData;
|
|
5
|
+
private formatDate;
|
|
6
|
+
transform(time: string | number | dayjs.Dayjs | undefined | null, format?: string, lang?: string): string;
|
|
10
7
|
static ɵfac: i0.ɵɵFactoryDeclaration<LibsUiPipesFormatDatePipe, never>;
|
|
11
8
|
static ɵpipe: i0.ɵɵPipeDeclaration<LibsUiPipesFormatDatePipe, "LibsUiPipesFormatDatePipe", true>;
|
|
12
9
|
}
|