@tmlmobilidade/utils 20250601.1211.21 → 20250601.1223.39
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/dist/src/dates/dates.js +20 -21
- package/package.json +1 -1
package/dist/src/dates/dates.js
CHANGED
|
@@ -33,10 +33,10 @@ class Dates {
|
|
|
33
33
|
* @param format - The format string (see Luxon tokens documentation)
|
|
34
34
|
* @returns A new Dates object parsed from the string
|
|
35
35
|
*/
|
|
36
|
-
static fromFormat(text, format, timezone) {
|
|
37
|
-
const dateTime = DateTime
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
static fromFormat(text, format, timezone = 'Europe/Lisbon') {
|
|
37
|
+
const dateTime = DateTime
|
|
38
|
+
.fromFormat(text, format)
|
|
39
|
+
.setZone(timezone);
|
|
40
40
|
return new Dates({
|
|
41
41
|
iso: dateTime.toISO(),
|
|
42
42
|
js_date: dateTime.toJSDate(),
|
|
@@ -63,10 +63,10 @@ class Dates {
|
|
|
63
63
|
* @param date - The JavaScript Date object to convert
|
|
64
64
|
* @returns A new Dates object created from the Date
|
|
65
65
|
*/
|
|
66
|
-
static fromJSDate(date, timezone) {
|
|
67
|
-
const dateTime = DateTime
|
|
68
|
-
|
|
69
|
-
|
|
66
|
+
static fromJSDate(date, timezone = 'Europe/Lisbon') {
|
|
67
|
+
const dateTime = DateTime
|
|
68
|
+
.fromJSDate(date)
|
|
69
|
+
.setZone(timezone);
|
|
70
70
|
return new Dates({
|
|
71
71
|
iso: dateTime.toISO(),
|
|
72
72
|
js_date: dateTime.toJSDate(),
|
|
@@ -79,10 +79,10 @@ class Dates {
|
|
|
79
79
|
* @param millis - The number of milliseconds since Unix epoch
|
|
80
80
|
* @returns A new Dates object created from the milliseconds timestamp
|
|
81
81
|
*/
|
|
82
|
-
static fromMillis(millis, timezone) {
|
|
83
|
-
const dateTime = DateTime
|
|
84
|
-
|
|
85
|
-
|
|
82
|
+
static fromMillis(millis, timezone = 'Europe/Lisbon') {
|
|
83
|
+
const dateTime = DateTime
|
|
84
|
+
.fromMillis(millis)
|
|
85
|
+
.setZone(timezone);
|
|
86
86
|
return new Dates({
|
|
87
87
|
iso: dateTime.toISO(),
|
|
88
88
|
js_date: dateTime.toJSDate(),
|
|
@@ -95,10 +95,10 @@ class Dates {
|
|
|
95
95
|
* @param date - The operational date in 'yyyyMMdd' format
|
|
96
96
|
* @returns A new Dates object created from the operational date
|
|
97
97
|
*/
|
|
98
|
-
static fromOperationalDate(date, timezone) {
|
|
99
|
-
const dateTime = DateTime
|
|
100
|
-
|
|
101
|
-
|
|
98
|
+
static fromOperationalDate(date, timezone = 'Europe/Lisbon') {
|
|
99
|
+
const dateTime = DateTime
|
|
100
|
+
.fromFormat(date, OPERATIONAL_DATE_FORMAT)
|
|
101
|
+
.setZone(timezone);
|
|
102
102
|
return new Dates({
|
|
103
103
|
iso: dateTime.toISO(),
|
|
104
104
|
js_date: dateTime.toJSDate(),
|
|
@@ -111,10 +111,10 @@ class Dates {
|
|
|
111
111
|
* @param seconds - The number of seconds since Unix epoch
|
|
112
112
|
* @returns A new Dates object created from the seconds timestamp
|
|
113
113
|
*/
|
|
114
|
-
static fromSeconds(seconds, timezone) {
|
|
115
|
-
const dateTime = DateTime
|
|
116
|
-
|
|
117
|
-
|
|
114
|
+
static fromSeconds(seconds, timezone = 'Europe/Lisbon') {
|
|
115
|
+
const dateTime = DateTime
|
|
116
|
+
.fromSeconds(seconds)
|
|
117
|
+
.setZone(timezone);
|
|
118
118
|
return new Dates({
|
|
119
119
|
iso: dateTime.toISO(),
|
|
120
120
|
js_date: dateTime.toJSDate(),
|
|
@@ -236,7 +236,6 @@ class Dates {
|
|
|
236
236
|
if (!this.iso)
|
|
237
237
|
throw new Error('ISO date is not set.');
|
|
238
238
|
const dateTime = DateTime.fromISO(this.iso).setZone(timezone);
|
|
239
|
-
this.timezone = timezone;
|
|
240
239
|
return new Dates({
|
|
241
240
|
iso: dateTime.toISO(),
|
|
242
241
|
js_date: dateTime.toJSDate(),
|
package/package.json
CHANGED