@libs-ui/pipes-format-date 0.2.356-9 → 0.2.357-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.
package/README.md CHANGED
@@ -1,39 +1,38 @@
1
1
  # @libs-ui/pipes-format-date
2
2
 
3
- > Bộ đôi pipe hỗ trợ định dạng thời gian và khởi tạo đối tượng Dayjs cho Angular 18+.
3
+ > Bộ đôi pipe standalone để định dạng thời gian và khởi tạo đối tượng Dayjs trong Angular template.
4
4
 
5
5
  ## Giới thiệu
6
6
 
7
7
  `@libs-ui/pipes-format-date` cung cấp hai pipe standalone:
8
8
 
9
- - `LibsUiPipesFormatDatePipe`: Định dạng thời gian từ nhiều kiểu đầu vào (Date, ISO string, timestamp) thành chuỗi hiển thị.
10
- - `LibsUiPipesGetDayjsPipe`: Khởi tạo và trả về đối tượng Dayjs từ cấu hình cho trước.
9
+ - **`LibsUiPipesFormatDatePipe`**: Chuyển đổi các kiểu đầu vào thời gian (string, number/Unix timestamp, Dayjs object) thành chuỗi hiển thị theo định dạng tùy chỉnh, hỗ trợ đa ngôn ngữ.
10
+ - **`LibsUiPipesGetDayjsPipe`**: Nhận một config object và trả về đối tượng `dayjs.Dayjs`, cho phép gọi các method của Dayjs trực tiếp trong template (`.year()`, `.format()`, v.v.).
11
11
 
12
- Cả hai đều được thiết kế tối ưu, hỗ trợ đa ngôn ngữ tree-shaking.
12
+ Cả hai pipe đều Pure Pipe Angular chỉ thực thi lại `transform` khi tham số đầu vào (reference) thay đổi, giúp tránh tính toán lại không cần thiết.
13
13
 
14
- ### Tính năng
14
+ ## Tính năng
15
15
 
16
- - **Linh hoạt**: Chấp nhận đầu vào string, number, Date hoặc Dayjs object.
17
- - **Định dạng tùy biến**: Hỗ trợ mọi định dạng Dayjs cho phép.
18
- - **Đa ngôn ngữ**: Dễ dàng thay đổi locale (vi, en, ...).
19
- - **Hiệu năng**: Pure pipe, chỉ thực thi lại khi input tham chiếu thay đổi.
20
- - **Standalone**: Dễ dàng import vào bất kỳ component nào.
21
- - **Dayjs Integration**: Tích hợp sâu với thư viện xử thời gian mạnh mẽ.
16
+ - Chấp nhận đầu vào đa dạng: ISO string, Unix timestamp (seconds), `dayjs.Dayjs`, `null`, `undefined`
17
+ - Định dạng đầu ra hoàn toàn tùy chỉnh theo pháp Dayjs (vd: `DD/MM/YYYY`, `HH:mm:ss`, `dddd`)
18
+ - Hỗ trợ đa ngôn ngữ (vi, en, ...) thông qua tham số `lang`
19
+ - Hỗ trợ `formatInput` để parse chuỗi đầu vào định dạng không chuẩn (vd: `DD/MM/YYYY HH:mm`)
20
+ - Tích hợp múi giờ `Asia/Ho_Chi_Minh` theo mặc định thông qua `getDayjs` từ `@libs-ui/utils`
21
+ - Pure Pipe hiệu năng cao, chỉ tính toán lại khi input thay đổi
22
+ - Standalone — import trực tiếp vào component, không cần NgModule
22
23
 
23
24
  ## Khi nào sử dụng
24
25
 
25
- - Khi cần hiển thị ngày tháng năm trong template HTML theo định dạng chuẩn ( dụ: `DD/MM/YYYY`).
26
- - Khi cần track sự thay đổi thời gian trong template không muốn viết quá nhiều logic trong component class.
27
- - Khi cần lấy đối tượng Dayjs từ một config JSON trong template để thực hiện các phép tính ngày tháng nhanh.
26
+ - Cần hiển thị ngày/giờ theo định dạng cụ thể trong template HTML (vd: `DD/MM/YYYY`, `HH:mm`)
27
+ - Cần định dạng thời gian ngôn ngữ (thứ, tháng bằng tiếng Việt hoặc tiếng Anh)
28
+ - Cần parse chuỗi thời gian định dạng lạ (vd: `10/03/2025 15:12`) sang định dạng chuẩn
29
+ - Cần lấy đối tượng Dayjs trong template để gọi các method như `.year()`, `.month()`, `.diff()`
30
+ - Xử lý timestamp Unix (giây) nhận về từ API backend
28
31
 
29
32
  ## Cài đặt
30
33
 
31
34
  ```bash
32
- # npm
33
35
  npm install @libs-ui/pipes-format-date
34
-
35
- # yarn
36
- yarn add @libs-ui/pipes-format-date
37
36
  ```
38
37
 
39
38
  ## Import
@@ -46,73 +45,262 @@ import { LibsUiPipesFormatDatePipe, LibsUiPipesGetDayjsPipe } from '@libs-ui/pip
46
45
  imports: [LibsUiPipesFormatDatePipe, LibsUiPipesGetDayjsPipe],
47
46
  // ...
48
47
  })
49
- export class YourComponent {}
48
+ export class MyComponent {}
50
49
  ```
51
50
 
52
- ## Ví dụ
51
+ ## Ví dụ sử dụng
53
52
 
54
- ### Định dạng ngày tháng bản
53
+ ### 1. Định dạng mặc định (YYYY/MM/DD HH:mm)
55
54
 
56
- ```html
57
- <!-- Mặc định: YYYY/MM/DD HH:mm -->
58
- <span>{{ timestamp | LibsUiPipesFormatDatePipe }}</span>
55
+ ```typescript
56
+ import { Component } from '@angular/core';
57
+ import { LibsUiPipesFormatDatePipe } from '@libs-ui/pipes-format-date';
59
58
 
60
- <!-- Custom format -->
61
- <span>{{ dateString | LibsUiPipesFormatDatePipe:'DD/MM/YYYY' }}</span>
59
+ @Component({
60
+ standalone: true,
61
+ imports: [LibsUiPipesFormatDatePipe],
62
+ template: `
63
+ <p>{{ now | LibsUiPipesFormatDatePipe }}</p>
64
+ <!-- Output: 2024/12/25 10:30 -->
65
+ `,
66
+ })
67
+ export class OrderCreatedAtComponent {
68
+ now = Date.now() / 1000; // Unix timestamp tính bằng giây
69
+ }
62
70
  ```
63
71
 
64
- ### Định dạng với ngôn ngữ cụ thể
72
+ ### 2. Custom format và đa ngôn ngữ
73
+
74
+ ```typescript
75
+ import { Component } from '@angular/core';
76
+ import { LibsUiPipesFormatDatePipe } from '@libs-ui/pipes-format-date';
77
+
78
+ @Component({
79
+ standalone: true,
80
+ imports: [LibsUiPipesFormatDatePipe],
81
+ template: `
82
+ <!-- Chỉ lấy ngày tháng năm -->
83
+ <p>{{ dateStr | LibsUiPipesFormatDatePipe:'DD/MM/YYYY' }}</p>
84
+ <!-- Output: 25/12/2024 -->
85
+
86
+ <!-- Có giờ phút giây -->
87
+ <p>{{ dateStr | LibsUiPipesFormatDatePipe:'YYYY-MM-DD HH:mm:ss' }}</p>
88
+ <!-- Output: 2024-12-25 00:00:00 -->
89
+
90
+ <!-- Tên thứ tiếng Việt -->
91
+ <p>{{ timestamp | LibsUiPipesFormatDatePipe:'dddd, DD MMMM YYYY':'vi' }}</p>
92
+ <!-- Output: Thứ Hai, 20 Tháng Năm 2024 -->
93
+
94
+ <!-- Tên thứ tiếng Anh -->
95
+ <p>{{ timestamp | LibsUiPipesFormatDatePipe:'dddd, MMMM DD, YYYY':'en' }}</p>
96
+ <!-- Output: Monday, May 20, 2024 -->
97
+ `,
98
+ })
99
+ export class EventDateComponent {
100
+ dateStr = '2024-12-25';
101
+ timestamp = 1716222600; // May 20, 2024 15:30:00 GMT+7
102
+ }
103
+ ```
104
+
105
+ ### 3. Custom input format (parse chuỗi định dạng lạ)
106
+
107
+ ```typescript
108
+ import { Component } from '@angular/core';
109
+ import { LibsUiPipesFormatDatePipe } from '@libs-ui/pipes-format-date';
110
+
111
+ @Component({
112
+ standalone: true,
113
+ imports: [LibsUiPipesFormatDatePipe],
114
+ template: `
115
+ <!--
116
+ Chuỗi đầu vào có định dạng DD/MM/YYYY HH:mm → cần truyền formatInput
117
+ để dayjs parse đúng trước khi định dạng lại đầu ra
118
+ -->
119
+ <p>
120
+ {{ rawDate | LibsUiPipesFormatDatePipe:'YYYY/MM/DD HH:mm':undefined:'DD/MM/YYYY HH:mm' }}
121
+ </p>
122
+ <!-- Output: 2025/03/10 15:12 -->
123
+ `,
124
+ })
125
+ export class ImportedDateComponent {
126
+ rawDate = '10/03/2025 15:12';
127
+ }
128
+ ```
129
+
130
+ ### 4. Lấy đối tượng Dayjs trong template (LibsUiPipesGetDayjsPipe)
131
+
132
+ ```typescript
133
+ import { Component } from '@angular/core';
134
+ import { LibsUiPipesGetDayjsPipe } from '@libs-ui/pipes-format-date';
135
+
136
+ @Component({
137
+ standalone: true,
138
+ imports: [LibsUiPipesGetDayjsPipe],
139
+ template: `
140
+ @let dayjsObj = (dayjsConfig | LibsUiPipesGetDayjsPipe);
141
+
142
+ @if (dayjsObj) {
143
+ <p>Year: {{ dayjsObj.year() }}</p>
144
+ <p>Month: {{ dayjsObj.month() + 1 }}</p>
145
+ <p>Formatted: {{ dayjsObj.format('DD-MM-YYYY') }}</p>
146
+ }
147
+ `,
148
+ })
149
+ export class DateInfoComponent {
150
+ dayjsConfig = { date: '2024-05-20' };
151
+ }
152
+ ```
153
+
154
+ ### 5. Dùng `formatDate` trực tiếp trong TypeScript (không inject pipe)
155
+
156
+ Pipe chỉ là thin wrapper của hàm `formatDate` từ `@libs-ui/utils`. Khi cần dùng trong logic TypeScript, import thẳng hàm đó — không cần inject pipe.
157
+
158
+ ```typescript
159
+ import { formatDate } from '@libs-ui/utils';
160
+
161
+ // Định dạng mặc định
162
+ const result1 = formatDate(Date.now() / 1000);
163
+ // Output: '2024/12/25 10:30'
164
+
165
+ // Custom format
166
+ const result2 = formatDate('2024-12-25', 'DD/MM/YYYY');
167
+ // Output: '25/12/2024'
168
+
169
+ // Với ngôn ngữ tiếng Việt
170
+ const result3 = formatDate(1716222600, 'dddd, DD MMMM YYYY', 'vi');
171
+ // Output: 'Thứ Hai, 20 Tháng Năm 2024'
172
+
173
+ // Với formatInput để parse chuỗi định dạng lạ
174
+ const result4 = formatDate('10/03/2025 15:12', 'YYYY/MM/DD HH:mm', undefined, 'DD/MM/YYYY HH:mm');
175
+ // Output: '2025/03/10 15:12'
176
+ ```
177
+
178
+ ## Transform — LibsUiPipesFormatDatePipe
179
+
180
+ Pipe name: `LibsUiPipesFormatDatePipe`
181
+
182
+ **Cú pháp template:**
183
+
184
+ ```
185
+ value | LibsUiPipesFormatDatePipe : formatOutput : lang : formatInput
186
+ ```
187
+
188
+ | Tham số | Type | Bắt buộc | Default | Mô tả | Ví dụ |
189
+ |---|---|---|---|---|---|
190
+ | `time` (value) | `string \| number \| dayjs.Dayjs \| null \| undefined` | Không | `undefined` | Giá trị thời gian cần định dạng | `1716222600`, `'2024-12-25'`, `dayjsObj` |
191
+ | `formatOutput` | `string` | Không | `'YYYY/MM/DD HH:mm'` | Định dạng đầu ra theo cú pháp Dayjs | `'DD/MM/YYYY'`, `'HH:mm:ss'`, `'dddd, DD MMMM YYYY'` |
192
+ | `lang` | `string` | Không | `undefined` | Locale hiển thị cho thứ/tháng | `'vi'`, `'en'` |
193
+ | `formatInput` | `string` | Không | `undefined` | Định dạng của chuỗi đầu vào khi Dayjs không tự nhận diện được | `'DD/MM/YYYY HH:mm'`, `'MM-DD-YYYY'` |
194
+
195
+ **Ví dụ template:**
65
196
 
66
197
  ```html
67
- <span>{{ now | LibsUiPipesFormatDatePipe:'dddd, DD MMMM YYYY':'vi' }}</span>
198
+ {{ now | LibsUiPipesFormatDatePipe }}
199
+ {{ dateStr | LibsUiPipesFormatDatePipe:'DD/MM/YYYY' }}
200
+ {{ timestamp | LibsUiPipesFormatDatePipe:'dddd, DD MMMM YYYY':'vi' }}
201
+ {{ rawDate | LibsUiPipesFormatDatePipe:'YYYY/MM/DD':undefined:'DD/MM/YYYY' }}
202
+ ```
203
+
204
+ **Ví dụ standalone (không dùng template):**
205
+
206
+ ```typescript
207
+ import { LibsUiPipesFormatDatePipe } from '@libs-ui/pipes-format-date';
208
+
209
+ const pipe = new LibsUiPipesFormatDatePipe();
210
+
211
+ pipe.transform('2024-12-25');
212
+ // Output: '2024/12/25 00:00'
213
+
214
+ pipe.transform('2024-12-25', 'DD/MM/YYYY');
215
+ // Output: '25/12/2024'
216
+
217
+ pipe.transform(1716222600, 'dddd, DD MMMM YYYY', 'vi');
218
+ // Output: 'Thứ Hai, 20 Tháng Năm 2024'
219
+
220
+ pipe.transform('10/03/2025 15:12', 'DD/MM/YYYY HH:mm', undefined, 'DD/MM/YYYY HH:mm');
221
+ // Output: '10/03/2025 15:12'
222
+
223
+ pipe.transform(null);
224
+ // Output: '' (chuỗi rỗng — không throw lỗi)
225
+
226
+ pipe.transform(undefined);
227
+ // Output: '' (chuỗi rỗng — không throw lỗi)
68
228
  ```
69
229
 
70
- ### Lấy đối tượng Dayjs
230
+ ## Transform LibsUiPipesGetDayjsPipe
231
+
232
+ Pipe name: `LibsUiPipesGetDayjsPipe`
233
+
234
+ **Cú pháp template:**
235
+
236
+ ```
237
+ config | LibsUiPipesGetDayjsPipe
238
+ ```
239
+
240
+ | Tham số | Type | Bắt buộc | Mô tả | Ví dụ |
241
+ |---|---|---|---|---|
242
+ | `config` | `{ date?: dayjs.ConfigType; utc?: boolean; formatOfDate?: string }` | Không | `undefined` | Config để tạo đối tượng Dayjs. Nếu không truyền, trả về Dayjs hiện tại | `{ date: '2024-05-20' }`, `{ date: 1716222600, utc: true }` |
243
+ | `config.date` | `dayjs.ConfigType` | Không | `undefined` | Giá trị thời gian: string, number (Unix giây), Dayjs object | `'2024-05-20'`, `1716222600` |
244
+ | `config.utc` | `boolean` | Không | `undefined` | `true` để parse và trả về theo UTC | `true` |
245
+ | `config.formatOfDate` | `string` | Không | `undefined` | Định dạng của `config.date` khi là chuỗi không chuẩn | `'DD/MM/YYYY'` |
246
+
247
+ **Giá trị trả về:** `dayjs.Dayjs | undefined` — trả về `undefined` khi `config.date` không hợp lệ hoặc rỗng.
248
+
249
+ **Ví dụ template:**
71
250
 
72
251
  ```html
73
- @let dayjsObj = (config | LibsUiPipesGetDayjsPipe); @if (dayjsObj) {
74
- <span>Year: {{ dayjsObj.year() }}</span>
252
+ @let d = ({ date: '2024-05-20' } | LibsUiPipesGetDayjsPipe);
253
+ @if (d) {
254
+ <span>{{ d.format('DD/MM/YYYY') }}</span>
255
+ <span>{{ d.year() }} / {{ d.month() + 1 }}</span>
75
256
  }
76
257
  ```
77
258
 
78
- ## API
259
+ **Ví dụ standalone:**
260
+
261
+ ```typescript
262
+ import { LibsUiPipesGetDayjsPipe } from '@libs-ui/pipes-format-date';
263
+
264
+ const pipe = new LibsUiPipesGetDayjsPipe();
79
265
 
80
- ### LibsUiPipesFormatDatePipe
266
+ const d = pipe.transform({ date: '2024-05-20' });
267
+ // d là đối tượng dayjs.Dayjs
81
268
 
82
- #### Parameters
269
+ d?.format('DD/MM/YYYY'); // '20/05/2024'
270
+ d?.year(); // 2024
271
+ d?.month(); // 4 (zero-based)
83
272
 
84
- | Property | Type | Default | Description |
85
- | -------------- | ------------------------------------------------------ | -------------------- | ---------------------------------------------------------------------- |
86
- | `time` | `string \| number \| dayjs.Dayjs \| null \| undefined` | `undefined` | Giá trị thời gian cần định dạng |
87
- | `formatOutput` | `string` | `'YYYY/MM/DD HH:mm'` | Định dạng đầu ra mong muốn |
88
- | `lang` | `string` | `undefined` | Ngôn ngữ hiển thị (vi, en, ...) |
89
- | `formatInput` | `string` | `undefined` | Định dạng của chuỗi đầu vào (trường hợp dayjs không tự nhận diện được) |
273
+ pipe.transform(undefined); // Trả về dayjs() hiện tại
274
+ pipe.transform({ date: undefined }); // Trả về undefined
275
+ ```
90
276
 
91
- ### LibsUiPipesGetDayjsPipe
277
+ ## Lưu ý quan trọng
92
278
 
93
- #### Parameters
279
+ ⚠️ **Unix timestamp tính bằng giây, không phải milliseconds**: Backend thường trả về Unix timestamp theo giây (`1716222600`). Nếu bạn có timestamp theo milliseconds (JavaScript `Date.now()`), cần chia 1000 trước khi truyền vào pipe: `Date.now() / 1000`.
94
280
 
95
- | Property | Type | Default | Description |
96
- | -------- | ------------------------------------------------------ | ----------- | ------------------------------- |
97
- | `config` | `{ date?: any, utc?: boolean, formatOfDate?: string }` | `undefined` | Cấu hình để tạo đối tượng Dayjs |
281
+ ⚠️ **Múi giờ mặc định là Asia/Ho_Chi_Minh**: Pipe dùng `getDayjs` từ `@libs-ui/utils` — đã được cấu hình mặc định múi giờ `Asia/Ho_Chi_Minh`. Nếu cần múi giờ UTC, dùng `LibsUiPipesGetDayjsPipe` với `{ utc: true }`.
98
282
 
99
- ## Công nghệ
283
+ ⚠️ **Locale `lang` cần cấu hình Dayjs**: Tham số `lang` chỉ hoạt động với các locale đã được import và đăng ký trong Dayjs. Mặc định `@libs-ui/utils` đã đăng ký sẵn `vi` và `en`.
100
284
 
101
- | Technology | Version | Purpose |
102
- | -------------- | ---------- | -------------- |
103
- | Angular | 18+ | Framework |
104
- | Day.js | 1.11.5 | Date logic |
105
- | @libs-ui/utils | 0.2.355-15 | Core utilities |
285
+ ⚠️ **`formatInput` khi chuỗi đầu vào không chuẩn**: Nếu truyền chuỗi như `10/03/2025 15:12` mà không có `formatInput`, Dayjs có thể parse sai hoặc trả về `Invalid Date`. Luôn cung cấp `formatInput` khi chuỗi đầu vào không ở dạng ISO 8601.
106
286
 
107
- ## Demo
287
+ ⚠️ **Không dùng function trong template**: Không gọi `formatDate(...)` trực tiếp trong template interpolation. Hãy dùng pipe hoặc khai báo `computed()` trong TypeScript.
288
+
289
+ ```html
290
+ <!-- SAI — gọi function trong template, tính toán lại mỗi change detection cycle -->
291
+ <p>{{ formatDate(order.createdAt) }}</p>
108
292
 
109
- Chạy demo page để xem trực quan các ví dụ:
293
+ <!-- ĐÚNG dùng pipe -->
294
+ <p>{{ order.createdAt | LibsUiPipesFormatDatePipe:'DD/MM/YYYY' }}</p>
295
+ ```
296
+
297
+ ## Demo
110
298
 
111
299
  ```bash
112
- npm run demo
300
+ npx nx serve core-ui
113
301
  ```
114
302
 
115
- - Local: [http://localhost:4500/pipes/format-date](http://localhost:4500/pipes/format-date)
303
+ Truy cập: http://localhost:4500/pipes/format-date
116
304
 
117
305
  ## Unit Tests
118
306
 
@@ -120,7 +308,3 @@ npm run demo
120
308
  npx nx test pipes-format-date
121
309
  npx nx test pipes-format-date --coverage
122
310
  ```
123
-
124
- ## License
125
-
126
- MIT
@@ -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/get-dayjs.pipe.ts","../../../../../libs-ui/pipes/format-date/src/libs-ui-pipes-format-date.ts"],"sourcesContent":["import { Pipe, PipeTransform } from '@angular/core';\nimport dayjs from 'dayjs';\nimport { formatDate } from '@libs-ui/utils';\n\n@Pipe({\n name: 'LibsUiPipesFormatDatePipe',\n standalone: true,\n})\nexport class LibsUiPipesFormatDatePipe implements PipeTransform {\n /**\n * @description Lấy ra chuỗi thời gian hiển thị theo định dạng và ngôn ngữ\n * @param date thời gian cần định dạng\n * @param format định dạng thời gian muốn lấy ra\n * @param lang lấy theo ngôn ngữ\n */\n transform(time: string | number | dayjs.Dayjs | undefined | null, formatOutput = 'YYYY/MM/DD HH:mm', lang?: string, formatInput?: string): string {\n return formatDate(time, formatOutput, lang, formatInput);\n }\n}\n","import { Pipe, PipeTransform } from '@angular/core';\nimport { getDayjs } from '@libs-ui/utils';\nimport dayjs from 'dayjs';\n\n@Pipe({\n name: 'LibsUiPipesGetDayjsPipe',\n standalone: true,\n})\nexport class LibsUiPipesGetDayjsPipe implements PipeTransform {\n /**\n * @description Lấy đối tượng dayjs theo config\n * @param config nếu không có config sẽ trả về đối tượng dayjs là thời gian hiện tại\n * @param config.date thời gian cần lấy\n * @param config.utc true nếu muốn lấy thời gian UTC\n * @param config.formatOfDate định dạng thời gian đang được truyền vào\n */\n transform(config?: { date?: dayjs.ConfigType; utc?: boolean; formatOfDate?: string }): dayjs.Dayjs | undefined {\n return getDayjs(config);\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;MAQa,yBAAyB,CAAA;AACpC;;;;;AAKG;IACH,SAAS,CAAC,IAAsD,EAAE,YAAY,GAAG,kBAAkB,EAAE,IAAa,EAAE,WAAoB,EAAA;QACtI,OAAO,UAAU,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,WAAW,CAAC;IAC1D;wGATW,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,IAAI;AACjB,iBAAA;;;MCCY,uBAAuB,CAAA;AAClC;;;;;;AAMG;AACH,IAAA,SAAS,CAAC,MAA0E,EAAA;AAClF,QAAA,OAAO,QAAQ,CAAC,MAAM,CAAC;IACzB;wGAVW,uBAAuB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,IAAA,EAAA,CAAA;sGAAvB,uBAAuB,EAAA,YAAA,EAAA,IAAA,EAAA,IAAA,EAAA,yBAAA,EAAA,CAAA;;4FAAvB,uBAAuB,EAAA,UAAA,EAAA,CAAA;kBAJnC,IAAI;AAAC,YAAA,IAAA,EAAA,CAAA;AACJ,oBAAA,IAAI,EAAE,yBAAyB;AAC/B,oBAAA,UAAU,EAAE,IAAI;AACjB,iBAAA;;;ACPD;;AAEG;;;;"}
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/get-dayjs.pipe.ts","../../../../../libs-ui/pipes/format-date/src/libs-ui-pipes-format-date.ts"],"sourcesContent":["import { Pipe, PipeTransform } from '@angular/core';\nimport dayjs from 'dayjs';\nimport { formatDate } from '@libs-ui/utils';\n\n@Pipe({\n name: 'LibsUiPipesFormatDatePipe',\n standalone: true,\n})\nexport class LibsUiPipesFormatDatePipe implements PipeTransform {\n /**\n * @description Lấy ra chuỗi thời gian hiển thị theo định dạng và ngôn ngữ\n * @param date thời gian cần định dạng\n * @param format định dạng thời gian muốn lấy ra\n * @param lang lấy theo ngôn ngữ\n */\n transform(time: string | number | dayjs.Dayjs | undefined | null, formatOutput = 'YYYY/MM/DD HH:mm', lang?: string, formatInput?: string): string {\n return formatDate(time, formatOutput, lang, formatInput);\n }\n}\n","import { Pipe, PipeTransform } from '@angular/core';\nimport { getDayjs } from '@libs-ui/utils';\nimport dayjs from 'dayjs';\n\n@Pipe({\n name: 'LibsUiPipesGetDayjsPipe',\n standalone: true,\n})\nexport class LibsUiPipesGetDayjsPipe implements PipeTransform {\n /**\n * @description Lấy đối tượng dayjs theo config\n * @param config nếu không có config sẽ trả về đối tượng dayjs là thời gian hiện tại\n * @param config.date thời gian cần lấy\n * @param config.utc true nếu muốn lấy thời gian UTC\n * @param config.formatOfDate định dạng thời gian đang được truyền vào\n */\n transform(config?: { date?: dayjs.ConfigType; utc?: boolean; formatOfDate?: string }): dayjs.Dayjs | undefined {\n return getDayjs(config);\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;MAQa,yBAAyB,CAAA;AACpC;;;;;AAKG;IACH,SAAS,CAAC,IAAsD,EAAE,YAAY,GAAG,kBAAkB,EAAE,IAAa,EAAE,WAAoB,EAAA;QACtI,OAAO,UAAU,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;KAC1D;wGATU,yBAAyB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,IAAA,EAAA,CAAA,CAAA;sGAAzB,yBAAyB,EAAA,YAAA,EAAA,IAAA,EAAA,IAAA,EAAA,2BAAA,EAAA,CAAA,CAAA;;4FAAzB,yBAAyB,EAAA,UAAA,EAAA,CAAA;kBAJrC,IAAI;AAAC,YAAA,IAAA,EAAA,CAAA;AACJ,oBAAA,IAAI,EAAE,2BAA2B;AACjC,oBAAA,UAAU,EAAE,IAAI;AACjB,iBAAA,CAAA;;;MCCY,uBAAuB,CAAA;AAClC;;;;;;AAMG;AACH,IAAA,SAAS,CAAC,MAA0E,EAAA;AAClF,QAAA,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC;KACzB;wGAVU,uBAAuB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,IAAA,EAAA,CAAA,CAAA;sGAAvB,uBAAuB,EAAA,YAAA,EAAA,IAAA,EAAA,IAAA,EAAA,yBAAA,EAAA,CAAA,CAAA;;4FAAvB,uBAAuB,EAAA,UAAA,EAAA,CAAA;kBAJnC,IAAI;AAAC,YAAA,IAAA,EAAA,CAAA;AACJ,oBAAA,IAAI,EAAE,yBAAyB;AAC/B,oBAAA,UAAU,EAAE,IAAI;AACjB,iBAAA,CAAA;;;ACPD;;AAEG;;;;"}
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@libs-ui/pipes-format-date",
3
- "version": "0.2.356-9",
3
+ "version": "0.2.357-1",
4
4
  "peerDependencies": {
5
5
  "@angular/core": ">=18.0.0",
6
6
  "dayjs": "1.11.5",
7
- "@libs-ui/utils": "0.2.356-9"
7
+ "@libs-ui/utils": "0.2.357-1"
8
8
  },
9
9
  "sideEffects": false,
10
10
  "module": "fesm2022/libs-ui-pipes-format-date.mjs",