@ejfdelgado/ejflab-common 1.12.3 → 1.13.0
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/package.json +1 -1
- package/src/MyDates.js +52 -11
package/package.json
CHANGED
package/src/MyDates.js
CHANGED
|
@@ -136,44 +136,85 @@ class MyDates {
|
|
|
136
136
|
deadline: (mananaInicio.getTime() - hoy.getTime()),
|
|
137
137
|
};
|
|
138
138
|
}
|
|
139
|
+
// MyDates.getDefaults(args)
|
|
140
|
+
static getDefaults(args, currentYear, nextYears, myDefault = "") {
|
|
141
|
+
if (args instanceof Array) {
|
|
142
|
+
if (args.lenght == 1) {
|
|
143
|
+
currentYear = args[0];
|
|
144
|
+
nextYears = args[0];
|
|
145
|
+
} else if (args.lenght == 2) {
|
|
146
|
+
currentYear = args[0];
|
|
147
|
+
nextYears = args[1];
|
|
148
|
+
}
|
|
149
|
+
if (args.lenght >= 3) {
|
|
150
|
+
myDefault = args[2];
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return {
|
|
154
|
+
currentYear,
|
|
155
|
+
nextYears,
|
|
156
|
+
myDefault
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
139
160
|
static formatDateBasic(dateformat, now, ...args) {
|
|
161
|
+
const {
|
|
162
|
+
currentYear,
|
|
163
|
+
nextYears,
|
|
164
|
+
myDefault
|
|
165
|
+
} = MyDates.getDefaults(args, "opcion2", "opcion1", "Día / Mes / Año");
|
|
140
166
|
if (now instanceof Date) {
|
|
141
167
|
if (new Date().getFullYear() == now.getFullYear()) {
|
|
142
|
-
return dateformat(now,
|
|
168
|
+
return dateformat(now, currentYear);
|
|
143
169
|
} else {
|
|
144
|
-
return dateformat(now,
|
|
170
|
+
return dateformat(now, nextYears);
|
|
145
171
|
}
|
|
146
172
|
} else {
|
|
147
|
-
return
|
|
173
|
+
return myDefault;
|
|
148
174
|
}
|
|
149
175
|
}
|
|
150
176
|
static formatDateSimpleBasic(dateformat, now, ...args) {
|
|
177
|
+
const {
|
|
178
|
+
currentYear,
|
|
179
|
+
nextYears,
|
|
180
|
+
myDefault
|
|
181
|
+
} = MyDates.getDefaults(args, "simple2", "simple1", "Día / Mes / Año");
|
|
151
182
|
if (now instanceof Date) {
|
|
152
183
|
if (new Date().getFullYear() == now.getFullYear()) {
|
|
153
|
-
return dateformat(now,
|
|
184
|
+
return dateformat(now, currentYear);
|
|
154
185
|
} else {
|
|
155
|
-
return dateformat(now,
|
|
186
|
+
return dateformat(now, nextYears);
|
|
156
187
|
}
|
|
157
188
|
} else {
|
|
158
|
-
return
|
|
189
|
+
return myDefault;
|
|
159
190
|
}
|
|
160
191
|
}
|
|
161
192
|
static formatDateCompletoBasic(dateformat, now, ...args) {
|
|
193
|
+
const {
|
|
194
|
+
currentYear,
|
|
195
|
+
nextYears,
|
|
196
|
+
myDefault
|
|
197
|
+
} = MyDates.getDefaults(args, "completo2", "completo1", "Día / Mes / Año Hora:Minutos:Segundos");
|
|
162
198
|
if (now instanceof Date) {
|
|
163
199
|
if (new Date().getFullYear() == now.getFullYear()) {
|
|
164
|
-
return dateformat(now,
|
|
200
|
+
return dateformat(now, currentYear);
|
|
165
201
|
} else {
|
|
166
|
-
return dateformat(now,
|
|
202
|
+
return dateformat(now, nextYears);
|
|
167
203
|
}
|
|
168
204
|
} else {
|
|
169
|
-
return
|
|
205
|
+
return myDefault;
|
|
170
206
|
}
|
|
171
207
|
}
|
|
172
208
|
static formatTimeBasic(dateformat, now, ...args) {
|
|
209
|
+
const {
|
|
210
|
+
currentYear,
|
|
211
|
+
nextYears,
|
|
212
|
+
myDefault
|
|
213
|
+
} = MyDates.getDefaults(args, "opcion3", "opcion3", "Hora / Minuto");
|
|
173
214
|
if (now instanceof Date) {
|
|
174
|
-
return dateformat(now,
|
|
215
|
+
return dateformat(now, currentYear);
|
|
175
216
|
} else {
|
|
176
|
-
return
|
|
217
|
+
return myDefault;
|
|
177
218
|
}
|
|
178
219
|
}
|
|
179
220
|
static formatPayu(dateformat, now) {
|