@bereasoftware/time-guard 1.0.4 → 2.0.4
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.en.md +50 -14
- package/README.md +167 -133
- package/dist/calendars/index.cjs +1 -0
- package/dist/calendars/index.es.js +319 -0
- package/dist/full.cjs +1 -0
- package/dist/full.es.js +4341 -0
- package/dist/locales/index.cjs +1 -0
- package/dist/locales/index.es.js +2797 -0
- package/dist/plugins/advanced-format.cjs +1 -0
- package/dist/plugins/advanced-format.es.js +132 -0
- package/dist/plugins/duration.cjs +1 -0
- package/dist/plugins/duration.es.js +145 -0
- package/dist/plugins/relative-time.cjs +1 -0
- package/dist/plugins/relative-time.es.js +122 -0
- package/dist/time-guard.cjs +1 -1
- package/dist/time-guard.es.js +76 -3569
- package/dist/time-guard.iife.js +1 -1
- package/dist/time-guard.umd.js +1 -1
- package/dist/types/{index.d.ts → time-guard.d.ts} +18 -0
- package/package.json +42 -10
package/README.en.md
CHANGED
|
@@ -100,8 +100,31 @@ pnpm add @bereasoftware/time-guard
|
|
|
100
100
|
|
|
101
101
|
### Requirements
|
|
102
102
|
|
|
103
|
-
- **Node.js**
|
|
103
|
+
- **Node.js** 20.18.0+ (Temporal API support)
|
|
104
104
|
- **TypeScript** 5.0+ (optional but recommended)
|
|
105
|
+
- **@js-temporal/polyfill** >=0.5.0 (peer dependency)
|
|
106
|
+
|
|
107
|
+
### Modular Bundle
|
|
108
|
+
|
|
109
|
+
TimeGuard uses a modular architecture inspired by dayjs. The **core** weighs ~5KB gzip and includes only the essentials (TimeGuard, formatter, EN/ES, Gregorian). Locales, plugins, and calendars are loaded on demand:
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
// Lightweight core (~5KB gzip) - EN/ES only
|
|
113
|
+
import { TimeGuard } from '@bereasoftware/time-guard';
|
|
114
|
+
|
|
115
|
+
// Full bundle (core + polyfill + all locales/plugins/calendars)
|
|
116
|
+
import { TimeGuard } from '@bereasoftware/time-guard/full';
|
|
117
|
+
|
|
118
|
+
// On-demand modules
|
|
119
|
+
import { ALL_LOCALES } from '@bereasoftware/time-guard/locales';
|
|
120
|
+
import { IslamicCalendar } from '@bereasoftware/time-guard/calendars';
|
|
121
|
+
import relativeTimePlugin from '@bereasoftware/time-guard/plugins/relative-time';
|
|
122
|
+
import { Duration } from '@bereasoftware/time-guard/plugins/duration';
|
|
123
|
+
import advancedFormatPlugin from '@bereasoftware/time-guard/plugins/advanced-format';
|
|
124
|
+
|
|
125
|
+
// UMD for CDN / <script>
|
|
126
|
+
// <script src="unpkg.com/@bereasoftware/time-guard/dist/time-guard.umd.js"></script>
|
|
127
|
+
```
|
|
105
128
|
|
|
106
129
|
---
|
|
107
130
|
|
|
@@ -658,7 +681,10 @@ ISO 8601 duration support with advanced calculations.
|
|
|
658
681
|
|
|
659
682
|
```typescript
|
|
660
683
|
import { TimeGuard } from "@bereasoftware/time-guard";
|
|
661
|
-
import {
|
|
684
|
+
import {
|
|
685
|
+
Duration,
|
|
686
|
+
durationPlugin,
|
|
687
|
+
} from "@bereasoftware/time-guard/plugins/duration";
|
|
662
688
|
import { PluginManager } from "@bereasoftware/time-guard";
|
|
663
689
|
|
|
664
690
|
// Install plugin
|
|
@@ -1179,24 +1205,26 @@ npm run dev
|
|
|
1179
1205
|
```
|
|
1180
1206
|
time-guard/
|
|
1181
1207
|
├── src/
|
|
1182
|
-
│ ├── index.ts #
|
|
1183
|
-
│ ├──
|
|
1208
|
+
│ ├── index.ts # Lightweight core (~5KB gzip, EN/ES)
|
|
1209
|
+
│ ├── full.ts # Full bundle (all inclusive)
|
|
1210
|
+
│ ├── polyfill-loader.ts # Temporal polyfill loader
|
|
1184
1211
|
│ ├── time-guard.ts # Main class
|
|
1185
1212
|
│ ├── adapters/
|
|
1186
1213
|
│ │ └── temporal.adapter.ts # Temporal API wrapper
|
|
1214
|
+
│ ├── calendars/ # 6 calendar systems
|
|
1187
1215
|
│ ├── formatters/
|
|
1188
1216
|
│ │ └── date.formatter.ts # Format strategies
|
|
1189
|
-
│
|
|
1190
|
-
│
|
|
1191
|
-
│
|
|
1217
|
+
│ ├── locales/ # 40+ locale files
|
|
1218
|
+
│ ├── plugins/ # 3 plugins (relative-time, duration, advanced-format)
|
|
1219
|
+
│ └── types/ # Type definitions
|
|
1192
1220
|
├── test/
|
|
1193
1221
|
│ ├── time-guard.test.ts # Core tests
|
|
1194
1222
|
│ ├── advanced.test.ts # Advanced tests
|
|
1195
|
-
│
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1223
|
+
│ ├── comprehensive.test.ts # Integration tests
|
|
1224
|
+
│ ├── locales.test.ts # Locale tests
|
|
1225
|
+
│ ├── plugins.test.ts # Plugin tests
|
|
1226
|
+
│ └── bundle-size.test.ts # Bundle size validation
|
|
1227
|
+
└── vite.config.ts # Unified config (3 build modes)
|
|
1200
1228
|
```
|
|
1201
1229
|
|
|
1202
1230
|
---
|
|
@@ -1231,6 +1259,16 @@ See [LICENSE](LICENSE) file for details.
|
|
|
1231
1259
|
|
|
1232
1260
|
---
|
|
1233
1261
|
|
|
1262
|
+
## 🤝 Contributors
|
|
1263
|
+
|
|
1264
|
+
Thanks to all contributors!
|
|
1265
|
+
|
|
1266
|
+
<a href="https://github.com/Berea-Soft/time-guard/graphs/contributors">
|
|
1267
|
+
<img src="https://contrib.rocks/image?repo=Berea-Soft/time-guard" alt="contributors" />
|
|
1268
|
+
</a>
|
|
1269
|
+
|
|
1270
|
+
---
|
|
1271
|
+
|
|
1234
1272
|
## 📞 Support
|
|
1235
1273
|
|
|
1236
1274
|
For questions, issues, or feature requests:
|
|
@@ -1241,8 +1279,6 @@ For questions, issues, or feature requests:
|
|
|
1241
1279
|
|
|
1242
1280
|
---
|
|
1243
1281
|
|
|
1244
|
-
---
|
|
1245
|
-
|
|
1246
1282
|
## Built with ❤️ by Berea-Soft
|
|
1247
1283
|
|
|
1248
1284
|
A modern date/time library with SOLID principles and TypeScript
|
package/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# TimeGuard 🕐
|
|
2
2
|
|
|
3
3
|
> 📚 **Documentación disponible en otros idiomas:**
|
|
4
|
+
>
|
|
4
5
|
> - 🇪🇸 **Español** (este archivo - README.md)
|
|
5
6
|
> - 🇬🇧 [English](README.en.md)
|
|
6
7
|
|
|
@@ -104,8 +105,31 @@ pnpm add @bereasoftware/time-guard
|
|
|
104
105
|
|
|
105
106
|
### Requisitos
|
|
106
107
|
|
|
107
|
-
- **Node.js**
|
|
108
|
+
- **Node.js** 20.18.0+ (soporte de Temporal API)
|
|
108
109
|
- **TypeScript** 5.0+ (opcional pero recomendado)
|
|
110
|
+
- **@js-temporal/polyfill** >=0.5.0 (peer dependency)
|
|
111
|
+
|
|
112
|
+
### Bundle Modular
|
|
113
|
+
|
|
114
|
+
TimeGuard usa una arquitectura modular inspirada en dayjs. El **core** pesa ~5KB gzip e incluye solo lo esencial (TimeGuard, formatter, EN/ES, Gregoriano). Locales, plugins y calendarios se cargan bajo demanda:
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
// Core ligero (~5KB gzip) - solo EN/ES
|
|
118
|
+
import { TimeGuard } from "@bereasoftware/time-guard";
|
|
119
|
+
|
|
120
|
+
// Bundle completo (core + polyfill + todos los locales/plugins/calendarios)
|
|
121
|
+
import { TimeGuard } from "@bereasoftware/time-guard/full";
|
|
122
|
+
|
|
123
|
+
// Módulos bajo demanda
|
|
124
|
+
import { ALL_LOCALES } from "@bereasoftware/time-guard/locales";
|
|
125
|
+
import { IslamicCalendar } from "@bereasoftware/time-guard/calendars";
|
|
126
|
+
import relativeTimePlugin from "@bereasoftware/time-guard/plugins/relative-time";
|
|
127
|
+
import { Duration } from "@bereasoftware/time-guard/plugins/duration";
|
|
128
|
+
import advancedFormatPlugin from "@bereasoftware/time-guard/plugins/advanced-format";
|
|
129
|
+
|
|
130
|
+
// UMD para CDN / <script>
|
|
131
|
+
// <script src="unpkg.com/@bereasoftware/time-guard/dist/time-guard.umd.js"></script>
|
|
132
|
+
```
|
|
109
133
|
|
|
110
134
|
---
|
|
111
135
|
|
|
@@ -253,7 +277,7 @@ date.round({
|
|
|
253
277
|
|
|
254
278
|
TimeGuard incluye soporte para múltiples sistemas de calendario, extensible a través del gestor de calendarios:
|
|
255
279
|
|
|
256
|
-
###
|
|
280
|
+
### Calendarios Soportados
|
|
257
281
|
|
|
258
282
|
```typescript
|
|
259
283
|
import { TimeGuard, CalendarManager } from "@bereasoftware/time-guard";
|
|
@@ -284,9 +308,9 @@ console.log(gregorian.getWeekdayName(1)); // "Sunday"
|
|
|
284
308
|
console.log(gregorian.isLeapYear(2024)); // true
|
|
285
309
|
```
|
|
286
310
|
|
|
287
|
-
###
|
|
311
|
+
### Objetos de Calendario
|
|
288
312
|
|
|
289
|
-
####
|
|
313
|
+
#### Calendario Gregoriano
|
|
290
314
|
|
|
291
315
|
```typescript
|
|
292
316
|
import { GregorianCalendar } from "@bereasoftware/time-guard/calendars";
|
|
@@ -296,7 +320,7 @@ console.log(calendar.daysInMonth(2024, 2)); // 29 (leap year)
|
|
|
296
320
|
console.log(calendar.daysInYear(2024)); // 366
|
|
297
321
|
```
|
|
298
322
|
|
|
299
|
-
####
|
|
323
|
+
#### Calendario Islámico (Hijri)
|
|
300
324
|
|
|
301
325
|
```typescript
|
|
302
326
|
import { IslamicCalendar } from "@bereasoftware/time-guard/calendars";
|
|
@@ -306,7 +330,7 @@ console.log(calendar.getMonthName(9)); // "Ramadan"
|
|
|
306
330
|
console.log(calendar.isLeapYear(1445)); // true
|
|
307
331
|
```
|
|
308
332
|
|
|
309
|
-
####
|
|
333
|
+
#### Calendario Hebreo
|
|
310
334
|
|
|
311
335
|
```typescript
|
|
312
336
|
import { HebrewCalendar } from "@bereasoftware/time-guard/calendars";
|
|
@@ -316,7 +340,7 @@ console.log(calendar.getMonthName(1)); // "Tishrei"
|
|
|
316
340
|
console.log(calendar.isLeapYear(5784)); // true
|
|
317
341
|
```
|
|
318
342
|
|
|
319
|
-
####
|
|
343
|
+
#### Calendario Chino
|
|
320
344
|
|
|
321
345
|
```typescript
|
|
322
346
|
import { ChineseCalendar } from "@bereasoftware/time-guard/calendars";
|
|
@@ -325,7 +349,7 @@ const calendar = new ChineseCalendar();
|
|
|
325
349
|
const zodiac = calendar.getZodiacSign(2024); // "龙" (Dragon)
|
|
326
350
|
```
|
|
327
351
|
|
|
328
|
-
####
|
|
352
|
+
#### Calendario Japonés
|
|
329
353
|
|
|
330
354
|
```typescript
|
|
331
355
|
import { JapaneseCalendar } from "@bereasoftware/time-guard/calendars";
|
|
@@ -334,7 +358,7 @@ const calendar = new JapaneseCalendar();
|
|
|
334
358
|
console.log(calendar.getMonthName(3)); // "3月"
|
|
335
359
|
```
|
|
336
360
|
|
|
337
|
-
####
|
|
361
|
+
#### Calendario Budista
|
|
338
362
|
|
|
339
363
|
```typescript
|
|
340
364
|
import { BuddhistCalendar } from "@bereasoftware/time-guard/calendars";
|
|
@@ -348,11 +372,11 @@ console.log(calendar.isLeapYear(2567)); // true
|
|
|
348
372
|
|
|
349
373
|
## � Plugins
|
|
350
374
|
|
|
351
|
-
TimeGuard
|
|
375
|
+
TimeGuard incluye un sistema de plugins opcional para funcionalidad extendida:
|
|
352
376
|
|
|
353
|
-
###
|
|
377
|
+
### Plugins Disponibles
|
|
354
378
|
|
|
355
|
-
1. **
|
|
379
|
+
1. **Plugin de Tiempo Relativo** - Diferencias de tiempo legibles para humanos
|
|
356
380
|
|
|
357
381
|
```typescript
|
|
358
382
|
import { TimeGuard, PluginManager } from "@bereasoftware/time-guard";
|
|
@@ -364,7 +388,7 @@ TimeGuard includes an optional plugin system for extended functionality:
|
|
|
364
388
|
TimeGuard.from("2024-04-01").toNow(); // "in 19 days"
|
|
365
389
|
```
|
|
366
390
|
|
|
367
|
-
2. **
|
|
391
|
+
2. **Plugin de Duración** - Soporte de duración ISO 8601
|
|
368
392
|
|
|
369
393
|
```typescript
|
|
370
394
|
import { Duration } from "@bereasoftware/time-guard/plugins/duration";
|
|
@@ -374,7 +398,7 @@ TimeGuard includes an optional plugin system for extended functionality:
|
|
|
374
398
|
duration.asDays(); // 1159
|
|
375
399
|
```
|
|
376
400
|
|
|
377
|
-
3. **
|
|
401
|
+
3. **Plugin de Formato Avanzado** - Tokens de formato extendidos
|
|
378
402
|
|
|
379
403
|
```typescript
|
|
380
404
|
import advancedFormatPlugin from "@bereasoftware/time-guard/plugins/advanced-format";
|
|
@@ -391,104 +415,104 @@ TimeGuard includes an optional plugin system for extended functionality:
|
|
|
391
415
|
|
|
392
416
|
## �📚 Documentation
|
|
393
417
|
|
|
394
|
-
###
|
|
418
|
+
### Archivos de Documentación Principal
|
|
395
419
|
|
|
396
|
-
|
|
|
397
|
-
| ------------------------------------- | ------------------------------------------------------------------------- |
|
|
398
|
-
| [📖 ARCHITECTURE.md](ARCHITECTURE.md) | Deep dive into design patterns, SOLID principles, and system architecture |
|
|
420
|
+
| Documento | Propósito |
|
|
421
|
+
| ------------------------------------- | ------------------------------------------------------------------------- | ------------------------------------------------------------------------- |
|
|
422
|
+
| [📖 ARCHITECTURE.md](ARCHITECTURE.md) | Deep dive into design patterns, SOLID principles, and system architecture | Inmersión profunda en patrones de diseño, principios SOLID y arquitectura |
|
|
399
423
|
| [💡 EXAMPLES.md](EXAMPLES.md) | Real-world usage examples and common scenarios |
|
|
400
424
|
| [🌍 LOCALES.md](LOCALES.md) | Complete guide to localization and supported languages |
|
|
401
425
|
| [� PLUGINS.md](PLUGINS.md) | Plugin system documentation and usage guide |
|
|
402
426
|
| [�📖 API Reference](#api-overview) | Quick API reference (below) |
|
|
403
427
|
|
|
404
|
-
###
|
|
428
|
+
### Navegación Rápida
|
|
405
429
|
|
|
406
|
-
- **
|
|
407
|
-
- **
|
|
408
|
-
- **
|
|
409
|
-
- **
|
|
430
|
+
- **Inicio** → Comienza con [Inicio Rápido](#inicio-r%C3%A1pido) arriba
|
|
431
|
+
- **Uso Avanzado** → Ver [EXAMPLES.md](EXAMPLES.md)
|
|
432
|
+
- **Localización** → Ver [LOCALES.md](LOCALES.md)
|
|
433
|
+
- **Arquitectura** → Ver [ARCHITECTURE.md](ARCHITECTURE.md)
|
|
410
434
|
|
|
411
|
-
## 🌍
|
|
435
|
+
## 🌍 Locales Soportadas
|
|
412
436
|
|
|
413
|
-
TimeGuard
|
|
437
|
+
TimeGuard proporciona **más de 40 idiomas y variantes regionales** con soporte completo de internacionalización. Los locales se organizan por familia de idiomas para facilitar el descubrimiento.
|
|
414
438
|
|
|
415
|
-
###
|
|
439
|
+
### Formato de Código de Locale
|
|
416
440
|
|
|
417
|
-
|
|
441
|
+
Los códigos de locale siguen el patrón estándar `[language]-[region]`:
|
|
418
442
|
|
|
419
|
-
- `en` -
|
|
420
|
-
- `en-gb` -
|
|
421
|
-
- `es-mx` -
|
|
422
|
-
- `zh-cn` -
|
|
443
|
+
- `en` - Forma predeterminada (se usa si no se especifica variante de región)
|
|
444
|
+
- `en-gb` - Variante de región específica (Gran Bretaña)
|
|
445
|
+
- `es-mx` - Variante española para México
|
|
446
|
+
- `zh-cn` - Chino simplificado
|
|
423
447
|
|
|
424
|
-
###
|
|
448
|
+
### Locales Disponibles por Familia
|
|
425
449
|
|
|
426
|
-
|
|
450
|
+
####-🇬🇧 Inglés (4 variantes)
|
|
427
451
|
|
|
428
|
-
- `en` -
|
|
429
|
-
- `en-au` -
|
|
430
|
-
- `en-gb` -
|
|
431
|
-
- `en-ca` -
|
|
452
|
+
- `en` - Inglés (US)
|
|
453
|
+
- `en-au` - Inglés (Australia)
|
|
454
|
+
- `en-gb` - Inglés (Gran Bretaña)
|
|
455
|
+
- `en-ca` - Inglés (Canadá)
|
|
432
456
|
|
|
433
|
-
###
|
|
457
|
+
### Español (3 variantes)
|
|
434
458
|
|
|
435
|
-
- `es` -
|
|
436
|
-
- `es-mx` -
|
|
437
|
-
- `es-us` -
|
|
459
|
+
- `es` - Español (España)
|
|
460
|
+
- `es-mx` - Español (México)
|
|
461
|
+
- `es-us` - Español (US)
|
|
438
462
|
|
|
439
|
-
###
|
|
463
|
+
### Idiomas Románicos (5)
|
|
440
464
|
|
|
441
|
-
- `fr` -
|
|
442
|
-
- `it` -
|
|
443
|
-
- `pt` -
|
|
444
|
-
- `pt-br` -
|
|
445
|
-
- `ro` -
|
|
465
|
+
- `fr` - Francés
|
|
466
|
+
- `it` - Italiano
|
|
467
|
+
- `pt` - Portugués (Portugal)
|
|
468
|
+
- `pt-br` - Portugués (Brasil)
|
|
469
|
+
- `ro` - Rumano
|
|
446
470
|
|
|
447
|
-
###
|
|
471
|
+
### Idiomas Eslavos (4)
|
|
448
472
|
|
|
449
|
-
- `ru` -
|
|
450
|
-
- `pl` -
|
|
451
|
-
- `cs` -
|
|
452
|
-
- `sk` -
|
|
473
|
+
- `ru` - Ruso
|
|
474
|
+
- `pl` - Polaco
|
|
475
|
+
- `cs` - Checo
|
|
476
|
+
- `sk` - Eslovaco
|
|
453
477
|
|
|
454
|
-
###
|
|
478
|
+
### Idiomas Nórdicos (4)
|
|
455
479
|
|
|
456
|
-
- `sv` -
|
|
457
|
-
- `nb` -
|
|
458
|
-
- `da` -
|
|
459
|
-
- `fi` -
|
|
480
|
+
- `sv` - Sueco
|
|
481
|
+
- `nb` - Noruego (Bokmål)
|
|
482
|
+
- `da` - Danés
|
|
483
|
+
- `fi` - Finlandés
|
|
460
484
|
|
|
461
|
-
###
|
|
485
|
+
### Idiomas Asiáticos (7)
|
|
462
486
|
|
|
463
|
-
- `ja` -
|
|
464
|
-
- `zh-cn` -
|
|
465
|
-
- `zh-tw` -
|
|
466
|
-
- `ko` -
|
|
487
|
+
- `ja` - Japonés
|
|
488
|
+
- `zh-cn` - Chino (Simplificado)
|
|
489
|
+
- `zh-tw` - Chino (Tradicional)
|
|
490
|
+
- `ko` - Coreano
|
|
467
491
|
- `th` - Thai
|
|
468
|
-
- `vi` -
|
|
469
|
-
- `id` -
|
|
492
|
+
- `vi` - Vietnamita
|
|
493
|
+
- `id` - Indonesio
|
|
470
494
|
|
|
471
|
-
###
|
|
495
|
+
### Idiomas Europeos (7)
|
|
472
496
|
|
|
473
|
-
- `de` -
|
|
474
|
-
- `nl` -
|
|
475
|
-
- `el` -
|
|
476
|
-
- `hu` -
|
|
477
|
-
- `eu` -
|
|
478
|
-
- `ca` -
|
|
479
|
-
- `tr` -
|
|
497
|
+
- `de` - Alemán
|
|
498
|
+
- `nl` - Holandés
|
|
499
|
+
- `el` - Griego
|
|
500
|
+
- `hu` - Húngaro
|
|
501
|
+
- `eu` - Euskera
|
|
502
|
+
- `ca` - Catalán
|
|
503
|
+
- `tr` - Turco
|
|
480
504
|
|
|
481
|
-
###
|
|
505
|
+
### Oriente Medio y Asia del Sur (3)
|
|
482
506
|
|
|
483
|
-
- `ar` -
|
|
484
|
-
- `he` -
|
|
507
|
+
- `ar` - Árabe
|
|
508
|
+
- `he` - Hebreo
|
|
485
509
|
- `hi` - Hindi
|
|
486
510
|
|
|
487
511
|
---
|
|
488
512
|
|
|
489
|
-
###
|
|
513
|
+
### Guía de Uso de Locales
|
|
490
514
|
|
|
491
|
-
####
|
|
515
|
+
#### Configuración de Locales
|
|
492
516
|
|
|
493
517
|
```typescript
|
|
494
518
|
import { TimeGuard } from "@bereasoftware/time-guard";
|
|
@@ -512,7 +536,7 @@ TimeGuard.from("2024-03-13", { locale: "de" });
|
|
|
512
536
|
TimeGuard.now({ locale: "ja" });
|
|
513
537
|
```
|
|
514
538
|
|
|
515
|
-
####
|
|
539
|
+
#### Formateo en Diferentes Locales
|
|
516
540
|
|
|
517
541
|
```typescript
|
|
518
542
|
const date = TimeGuard.from("2024-03-13");
|
|
@@ -571,7 +595,7 @@ date.locale("he").format("DD.MM.YYYY"); // 13.03.2024
|
|
|
571
595
|
date.locale("hi").format("DD MMMM YYYY"); // 13 मार्च 2024
|
|
572
596
|
```
|
|
573
597
|
|
|
574
|
-
####
|
|
598
|
+
#### Nombres de Día y Mes
|
|
575
599
|
|
|
576
600
|
```typescript
|
|
577
601
|
// Get localized day names
|
|
@@ -589,7 +613,7 @@ date.locale("de").format("MMMM"); // März
|
|
|
589
613
|
date.locale("ru").format("MMMM"); // марта
|
|
590
614
|
```
|
|
591
615
|
|
|
592
|
-
####
|
|
616
|
+
#### Aplicaciones Multilocale
|
|
593
617
|
|
|
594
618
|
```typescript
|
|
595
619
|
// Switch language at runtime (user preference)
|
|
@@ -618,7 +642,7 @@ console.log(formatUserDate(date, "fr")); // mercredi, 13 mars 2024 à 14:30
|
|
|
618
642
|
console.log(formatUserDate(date, "ja")); // 水曜日、2024年3月13日 14:30
|
|
619
643
|
```
|
|
620
644
|
|
|
621
|
-
####
|
|
645
|
+
#### Obtener Locales Disponibles Programáticamente
|
|
622
646
|
|
|
623
647
|
```typescript
|
|
624
648
|
// Get all available locales
|
|
@@ -665,9 +689,9 @@ PluginManager.isInstalled(pluginName);
|
|
|
665
689
|
PluginManager.listInstalled();
|
|
666
690
|
```
|
|
667
691
|
|
|
668
|
-
### 1️⃣
|
|
692
|
+
### 1️⃣ Plugin de Tiempo Relativo
|
|
669
693
|
|
|
670
|
-
|
|
694
|
+
Añade diferencias de tiempo legibles como "hace 2 horas" o "en 3 días".
|
|
671
695
|
|
|
672
696
|
```typescript
|
|
673
697
|
import { TimeGuard, PluginManager } from "@bereasoftware/time-guard";
|
|
@@ -716,13 +740,16 @@ date.humanize(other, true); // "a month" (exact mode)
|
|
|
716
740
|
|
|
717
741
|
---
|
|
718
742
|
|
|
719
|
-
### 2️⃣
|
|
743
|
+
### 2️⃣ Plugin de Duración
|
|
720
744
|
|
|
721
|
-
ISO 8601
|
|
745
|
+
Soporte de duración ISO 8601 con cálculos avanzados.
|
|
722
746
|
|
|
723
747
|
```typescript
|
|
724
748
|
import { TimeGuard } from "@bereasoftware/time-guard";
|
|
725
|
-
import {
|
|
749
|
+
import {
|
|
750
|
+
Duration,
|
|
751
|
+
durationPlugin,
|
|
752
|
+
} from "@bereasoftware/time-guard/plugins/duration";
|
|
726
753
|
import { PluginManager } from "@bereasoftware/time-guard";
|
|
727
754
|
|
|
728
755
|
// Install plugin
|
|
@@ -807,9 +834,9 @@ Duration.fromISO("-P1D"); // Negative: -1 day
|
|
|
807
834
|
|
|
808
835
|
---
|
|
809
836
|
|
|
810
|
-
### 3️⃣
|
|
837
|
+
### 3️⃣ Plugin de Formato Avanzado
|
|
811
838
|
|
|
812
|
-
|
|
839
|
+
Tokens de formato extendidos para necesidades de formateo especializadas.
|
|
813
840
|
|
|
814
841
|
```typescript
|
|
815
842
|
import { TimeGuard, PluginManager } from "@bereasoftware/time-guard";
|
|
@@ -857,7 +884,7 @@ zzz // Timezone abbreviation (UTC, EST, etc.)
|
|
|
857
884
|
|
|
858
885
|
---
|
|
859
886
|
|
|
860
|
-
###
|
|
887
|
+
### Arquitectura de Plugins
|
|
861
888
|
|
|
862
889
|
All plugins implement `ITimeGuardPlugin`:
|
|
863
890
|
|
|
@@ -900,7 +927,7 @@ date.myMethod(); // "Hello from my plugin!"
|
|
|
900
927
|
|
|
901
928
|
---
|
|
902
929
|
|
|
903
|
-
## 🎯
|
|
930
|
+
## 🎯 Referencia API
|
|
904
931
|
|
|
905
932
|
### Factory Methods
|
|
906
933
|
|
|
@@ -1201,7 +1228,7 @@ Edge cases: 65+ tests
|
|
|
1201
1228
|
|
|
1202
1229
|
---
|
|
1203
1230
|
|
|
1204
|
-
## 🏛️
|
|
1231
|
+
## 🏛️ Arquitectura
|
|
1205
1232
|
|
|
1206
1233
|
TimeGuard is built on **SOLID principles** ensuring clean, maintainable, and extensible code:
|
|
1207
1234
|
|
|
@@ -1238,78 +1265,85 @@ npm run build
|
|
|
1238
1265
|
npm run dev
|
|
1239
1266
|
```
|
|
1240
1267
|
|
|
1241
|
-
###
|
|
1268
|
+
### Estructura del Proyecto
|
|
1242
1269
|
|
|
1243
1270
|
```
|
|
1244
1271
|
time-guard/
|
|
1245
1272
|
├── src/
|
|
1246
|
-
│ ├── index.ts #
|
|
1247
|
-
│ ├──
|
|
1248
|
-
│ ├──
|
|
1273
|
+
│ ├── index.ts # Core ligero (~5KB gzip, EN/ES)
|
|
1274
|
+
│ ├── full.ts # Bundle completo (todo incluido)
|
|
1275
|
+
│ ├── polyfill-loader.ts # Cargador del polyfill Temporal
|
|
1276
|
+
│ ├── time-guard.ts # Clase principal
|
|
1249
1277
|
│ ├── adapters/
|
|
1250
|
-
│ │ └── temporal.adapter.ts #
|
|
1278
|
+
│ │ └── temporal.adapter.ts # Wrapper del API Temporal
|
|
1279
|
+
│ ├── calendars/ # 6 sistemas de calendario
|
|
1251
1280
|
│ ├── formatters/
|
|
1252
|
-
│ │ └── date.formatter.ts #
|
|
1253
|
-
│
|
|
1254
|
-
│
|
|
1255
|
-
│
|
|
1256
|
-
│ ├── english.locale.ts # English variants
|
|
1257
|
-
│ ├── spanish.locale.ts # Spanish variants
|
|
1258
|
-
│ └── ... # 6+ more locale files
|
|
1281
|
+
│ │ └── date.formatter.ts # Estrategias de formateo
|
|
1282
|
+
│ ├── locales/ # 40+ archivos de locale
|
|
1283
|
+
│ ├── plugins/ # 3 plugins (relative-time, duration, advanced-format)
|
|
1284
|
+
│ └── types/ # Definiciones de tipos
|
|
1259
1285
|
├── test/
|
|
1260
|
-
│ ├── time-guard.test.ts #
|
|
1261
|
-
│ ├── advanced.test.ts #
|
|
1262
|
-
│
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1286
|
+
│ ├── time-guard.test.ts # Pruebas core
|
|
1287
|
+
│ ├── advanced.test.ts # Pruebas avanzadas
|
|
1288
|
+
│ ├── comprehensive.test.ts # Pruebas de integración
|
|
1289
|
+
│ ├── locales.test.ts # Pruebas de locales
|
|
1290
|
+
│ ├── plugins.test.ts # Pruebas de plugins
|
|
1291
|
+
│ └── bundle-size.test.ts # Validación de tamaño de bundle
|
|
1292
|
+
└── vite.config.ts # Config unificada (3 modos de build)
|
|
1267
1293
|
```
|
|
1268
1294
|
|
|
1269
1295
|
---
|
|
1270
1296
|
|
|
1271
|
-
## 🤝
|
|
1297
|
+
## 🤝 Contribuir
|
|
1272
1298
|
|
|
1273
|
-
|
|
1299
|
+
¡Bienvenidas las contribuciones! Por favor:
|
|
1274
1300
|
|
|
1275
|
-
1.
|
|
1276
|
-
2.
|
|
1277
|
-
3.
|
|
1278
|
-
4.
|
|
1279
|
-
5.
|
|
1301
|
+
1. Sigue los principios SOLID y patrones de código existentes
|
|
1302
|
+
2. Escribe pruebas para nuevas funcionalidades
|
|
1303
|
+
3. Actualiza la documentación
|
|
1304
|
+
4. Asegúrate de que todas las pruebas pasen (`npm test`)
|
|
1305
|
+
5. Verifica que los tipos pasen (`npx tsc --noEmit`)
|
|
1280
1306
|
|
|
1281
1307
|
---
|
|
1282
1308
|
|
|
1283
|
-
## 📄
|
|
1309
|
+
## 📄 Licencia
|
|
1284
1310
|
|
|
1285
|
-
MIT
|
|
1311
|
+
Licencia MIT © 2024 Berea-Soft
|
|
1286
1312
|
|
|
1287
|
-
|
|
1313
|
+
Ver archivo [LICENSE](LICENSE) para detalles.
|
|
1288
1314
|
|
|
1289
1315
|
---
|
|
1290
1316
|
|
|
1291
|
-
## 🔗
|
|
1317
|
+
## 🔗 Enlaces Rápidos
|
|
1292
1318
|
|
|
1293
|
-
- 📖 [
|
|
1294
|
-
- 🏛️ [
|
|
1295
|
-
- 🌍 [
|
|
1296
|
-
- 🐛 [
|
|
1297
|
-
- 💬 [
|
|
1319
|
+
- 📖 [Referencia API Completa](EXAMPLES.md)
|
|
1320
|
+
- 🏛️ [Guía de Arquitectura](ARCHITECTURE.md)
|
|
1321
|
+
- 🌍 [Guía de Localización](LOCALES.md)
|
|
1322
|
+
- 🐛 [Rastreador de Problemas](https://github.com/bereasoftware/time-guard/issues)
|
|
1323
|
+
- 💬 [Discusiones](https://github.com/bereasoftware/time-guard/discussions)
|
|
1298
1324
|
|
|
1299
1325
|
---
|
|
1300
1326
|
|
|
1301
|
-
##
|
|
1327
|
+
## 🤝 Contribuidores
|
|
1302
1328
|
|
|
1303
|
-
|
|
1329
|
+
¡Gracias a todos los que han contribuido!
|
|
1304
1330
|
|
|
1305
|
-
-
|
|
1306
|
-
-
|
|
1307
|
-
|
|
1331
|
+
<a href="https://github.com/Berea-Soft/time-guard/graphs/contributors">
|
|
1332
|
+
<img src="https://contrib.rocks/image?repo=Berea-Soft/time-guard" alt="contribuidores" />
|
|
1333
|
+
</a>
|
|
1308
1334
|
|
|
1309
1335
|
---
|
|
1310
1336
|
|
|
1337
|
+
## 📞 Soporte
|
|
1338
|
+
|
|
1339
|
+
Para preguntas, problemas o solicitudes de funciones:
|
|
1340
|
+
|
|
1341
|
+
- Abre un problema en GitHub
|
|
1342
|
+
- Inicia una discusión
|
|
1343
|
+
- Consulta la documentación existente
|
|
1344
|
+
|
|
1311
1345
|
---
|
|
1312
1346
|
|
|
1313
|
-
|
|
1347
|
+
Construído con ❤️ por Berea-Soft
|
|
1314
1348
|
|
|
1315
|
-
|
|
1349
|
+
Una librería moderna de fecha/hora con principios SOLID y TypeScript
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=class{id=`islamic`;name=`Islamic Calendar (Hijri)`;locale=`ar`;monthNames=[`Muharram`,`Safar`,`Rabi al-awwal`,`Rabi al-thani`,`Jumada al-awwal`,`Jumada al-thani`,`Rajab`,`Sha'ban`,`Ramadan`,`Shawwal`,`Dhu al-Qi'dah`,`Dhu al-Hijjah`];getMonthName(e){return this.monthNames[Math.max(0,Math.min(11,e-1))]}getWeekdayName(e,t=!1){return(t?[`Ahd`,`Ith`,`Sel`,`Rab`,`Kha`,`Jum`,`Sab`]:[`Ahad`,`Ithnayn`,`Salasa`,`Rabi`,`Khamis`,`Jumah`,`Sabt`])[Math.max(0,Math.min(6,e-1))]}isLeapYear(e){return[2,5,7,10,13,16,18,21,24,26,29].includes(e%30)}daysInMonth(e,t){return t%2==1||t===12&&this.isLeapYear(e)?30:29}daysInYear(e){return this.isLeapYear(e)?355:354}},t=class{id=`hebrew`;name=`Hebrew Calendar`;locale=`he`;monthNames=[`Tishrei`,`Cheshvan`,`Kislev`,`Tevet`,`Shevat`,`Adar`,`Nisan`,`Iyar`,`Sivan`,`Tammuz`,`Av`,`Elul`];getMonthName(e){return this.monthNames[Math.max(0,Math.min(11,e-1))]}getWeekdayName(e,t=!1){return(t?[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`]:[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`])[Math.max(0,Math.min(6,e-1))]}isLeapYear(e){return[3,6,8,11,14,17,19].includes(e%19)}daysInMonth(e,t){return[30,29,30,29,30,29,30,29,30,29,30,29][Math.max(0,Math.min(11,t-1))]}daysInYear(e){return this.isLeapYear(e)?384:354}},n=class{id=`chinese`;name=`Chinese Calendar`;locale=`zh`;monthNames=[`正月`,`二月`,`三月`,`四月`,`五月`,`六月`,`七月`,`八月`,`九月`,`十月`,`冬月`,`腊月`];terrestrialBranches=[`子`,`丑`,`寅`,`卯`,`辰`,`巳`,`午`,`未`,`申`,`酉`,`戌`,`亥`];getMonthName(e){return this.monthNames[Math.max(0,Math.min(11,e-1))]}getWeekdayName(e,t=!1){return(t?[`日`,`一`,`二`,`三`,`四`,`五`,`六`]:[`星期日`,`星期一`,`星期二`,`星期三`,`星期四`,`星期五`,`星期六`])[Math.max(0,Math.min(6,e-1))]}isLeapYear(e){return e%3==0}daysInMonth(e,t){return t%2==0?30:29}daysInYear(e){return this.isLeapYear(e)?384:354}getZodiacSign(e){return this.terrestrialBranches[e%12]}},r=class{id=`japanese`;name=`Japanese Calendar`;locale=`ja`;monthNames=[`1月`,`2月`,`3月`,`4月`,`5月`,`6月`,`7月`,`8月`,`9月`,`10月`,`11月`,`12月`];getMonthName(e){return this.monthNames[Math.max(0,Math.min(11,e-1))]}getWeekdayName(e,t=!1){return(t?[`日`,`月`,`火`,`水`,`木`,`金`,`土`]:[`日曜日`,`月曜日`,`火曜日`,`水曜日`,`木曜日`,`金曜日`,`土曜日`])[Math.max(0,Math.min(6,e-1))]}isLeapYear(e){return e%4==0&&e%100!=0||e%400==0}daysInMonth(e,t){return t===2&&this.isLeapYear(e)?29:[31,28,31,30,31,30,31,31,30,31,30,31][Math.max(0,Math.min(11,t-1))]}daysInYear(e){return this.isLeapYear(e)?366:365}},i=class{id=`buddhist`;name=`Buddhist Calendar`;locale=`th`;monthNames=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`];getMonthName(e){return this.monthNames[Math.max(0,Math.min(11,e-1))]}getWeekdayName(e){return[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`][Math.max(0,Math.min(6,e-1))]}isLeapYear(e){let t=e-543;return t%4==0&&t%100!=0||t%400==0}daysInMonth(e,t){return t===2&&this.isLeapYear(e)?29:[31,28,31,30,31,30,31,31,30,31,30,31][Math.max(0,Math.min(11,t-1))]}daysInYear(e){return this.isLeapYear(e)?366:365}};exports.BuddhistCalendar=i,exports.ChineseCalendar=n,exports.HebrewCalendar=t,exports.IslamicCalendar=e,exports.JapaneseCalendar=r;
|