@osimatic/helpers-js 1.1.50 → 1.1.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.
- package/date_time.js +11 -10
- package/form_date.js +38 -38
- package/package.json +1 -1
package/date_time.js
CHANGED
|
@@ -63,7 +63,7 @@ class DateTimeFormatter {
|
|
|
63
63
|
|
|
64
64
|
return this.timeDigitalFormatter[timeZone+locale];
|
|
65
65
|
}
|
|
66
|
-
}
|
|
66
|
+
}
|
|
67
67
|
|
|
68
68
|
class DateTime {
|
|
69
69
|
static getSqlDate(jsDate, timeZone="Europe/Paris") {
|
|
@@ -147,15 +147,15 @@ class DateTime {
|
|
|
147
147
|
static getDay(jsDate) {
|
|
148
148
|
return jsDate.getUTCDate();
|
|
149
149
|
}
|
|
150
|
-
|
|
150
|
+
|
|
151
151
|
static getDayOfMonth(jsDate) {
|
|
152
152
|
return jsDate.getUTCDate();
|
|
153
153
|
}
|
|
154
|
-
|
|
154
|
+
|
|
155
155
|
static getDayOfWeek(jsDate) {
|
|
156
156
|
return jsDate.getUTCDay();
|
|
157
157
|
}
|
|
158
|
-
|
|
158
|
+
|
|
159
159
|
static getDayName(jsDate, locale="fr-FR", isShort=false) {
|
|
160
160
|
return jsDate.toLocaleDateString(locale, {weekday: (isShort?'short':'long')});
|
|
161
161
|
}
|
|
@@ -277,7 +277,7 @@ class DateTime {
|
|
|
277
277
|
return jsDateTime > today;
|
|
278
278
|
}
|
|
279
279
|
|
|
280
|
-
static getNbDayBetweenTwo(jsDate1, jsDate2, asPeriod, timeZone="Europe/Paris") {
|
|
280
|
+
static getNbDayBetweenTwo(jsDate1, jsDate2, asPeriod=false, timeZone="Europe/Paris") {
|
|
281
281
|
//jsDate1.set
|
|
282
282
|
if (jsDate1 == null || jsDate2 == null) {
|
|
283
283
|
return 0;
|
|
@@ -371,7 +371,7 @@ class TimestampUnix {
|
|
|
371
371
|
return DateTime.isDateEqual(this.parse(timestamp1), this.parse(timestamp2));
|
|
372
372
|
}
|
|
373
373
|
|
|
374
|
-
static getNbDayBetweenTwo(timestamp1, timestamp2, asPeriod, timeZone="Europe/Paris") {
|
|
374
|
+
static getNbDayBetweenTwo(timestamp1, timestamp2, asPeriod=false, timeZone="Europe/Paris") {
|
|
375
375
|
return DateTime.getNbDayBetweenTwo(this.parse(timestamp1), this.parse(timestamp2), asPeriod, timeZone);
|
|
376
376
|
}
|
|
377
377
|
|
|
@@ -437,7 +437,9 @@ class SqlDate {
|
|
|
437
437
|
static isDateInTheFuture(sqlDate) {
|
|
438
438
|
return DateTime.isDateInTheFuture(SqlDateTime.parse(sqlDate + " 00:00:00"));
|
|
439
439
|
}
|
|
440
|
-
|
|
440
|
+
static getNbDayBetweenTwo(sqlDate1, sqlDate2, asPeriod=false) {
|
|
441
|
+
return DateTime.getNbDayBetweenTwo(SqlDateTime.parse(sqlDate1 + " 00:00:00"), SqlDateTime.parse(sqlDate2 + " 00:00:00"), asPeriod);
|
|
442
|
+
}
|
|
441
443
|
}
|
|
442
444
|
|
|
443
445
|
/**
|
|
@@ -448,7 +450,7 @@ class SqlTime {
|
|
|
448
450
|
if (sqlTime == null) {
|
|
449
451
|
return null;
|
|
450
452
|
}
|
|
451
|
-
|
|
453
|
+
|
|
452
454
|
if ((sqlTime.match(/\:/g) || []).length == 1) {
|
|
453
455
|
sqlTime += ':00';
|
|
454
456
|
}
|
|
@@ -483,7 +485,6 @@ class SqlTime {
|
|
|
483
485
|
static getTimestamp(sqlTime) {
|
|
484
486
|
return SqlDateTime.getTimestamp('1970-01-01 '+sqlTime);
|
|
485
487
|
}
|
|
486
|
-
|
|
487
488
|
}
|
|
488
489
|
|
|
489
490
|
/**
|
|
@@ -569,7 +570,7 @@ class SqlDateTime {
|
|
|
569
570
|
return DateTime.isDateTimeInTheFuture(this.parse(sqlDateTime));
|
|
570
571
|
}
|
|
571
572
|
|
|
572
|
-
static getNbDayBetweenTwo(sqlDateTime1, sqlDateTime2, asPeriod) {
|
|
573
|
+
static getNbDayBetweenTwo(sqlDateTime1, sqlDateTime2, asPeriod=false) {
|
|
573
574
|
return DateTime.getNbDayBetweenTwo(this.parse(sqlDateTime1), this.parse(sqlDateTime2), asPeriod);
|
|
574
575
|
}
|
|
575
576
|
|
package/form_date.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// input period de type : Du <input type="date" name="start_date" /> au <input type="date" name="end_date" />
|
|
2
2
|
class InputPeriod {
|
|
3
3
|
|
|
4
|
-
static addLinks(form
|
|
4
|
+
static addLinks(form) {
|
|
5
5
|
let divParent = form.find('input[type="date"][data-add_period_select_links]').parent();
|
|
6
6
|
if (divParent.hasClass('input-group')) {
|
|
7
7
|
divParent = divParent.parent();
|
|
@@ -16,98 +16,98 @@ class InputPeriod {
|
|
|
16
16
|
+'<a href="#" class="period_select_current_year">Cette année</a>'
|
|
17
17
|
+'</div>'
|
|
18
18
|
);
|
|
19
|
-
this.init(form
|
|
19
|
+
this.init(form);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
static init(form
|
|
22
|
+
static init(form) {
|
|
23
23
|
let link;
|
|
24
24
|
//console.log(form.find('a.period_select_current_week'));
|
|
25
25
|
|
|
26
26
|
if ((link = form.find('a.period_select_today')).length) {
|
|
27
|
-
link.click(function() { InputPeriod.selectToday($(this)
|
|
27
|
+
link.click(function() { InputPeriod.selectToday($(this)); return false; });
|
|
28
28
|
}
|
|
29
29
|
if ((link = form.find('a.period_select_yesterday')).length) {
|
|
30
|
-
link.click(function() { InputPeriod.selectPreviousDay($(this), 1
|
|
30
|
+
link.click(function() { InputPeriod.selectPreviousDay($(this), 1); return false; });
|
|
31
31
|
}
|
|
32
32
|
if ((link = form.find('a.period_select_tomorrow')).length) {
|
|
33
|
-
link.click(function() { InputPeriod.selectFollowingDay($(this), 1
|
|
33
|
+
link.click(function() { InputPeriod.selectFollowingDay($(this), 1); return false; });
|
|
34
34
|
}
|
|
35
35
|
if ((link = form.find('a.period_select_current_week')).length) {
|
|
36
|
-
link.click(function() { InputPeriod.selectCurrentWeek($(this)
|
|
36
|
+
link.click(function() { InputPeriod.selectCurrentWeek($(this)); return false; });
|
|
37
37
|
}
|
|
38
38
|
if ((link = form.find('a.period_select_last_week')).length) {
|
|
39
|
-
link.click(function() { InputPeriod.selectPreviousWeek($(this), 1
|
|
39
|
+
link.click(function() { InputPeriod.selectPreviousWeek($(this), 1); return false; });
|
|
40
40
|
}
|
|
41
41
|
if ((link = form.find('a.period_select_current_month')).length) {
|
|
42
|
-
link.click(function() { InputPeriod.selectCurrentMonth($(this)
|
|
42
|
+
link.click(function() { InputPeriod.selectCurrentMonth($(this)); return false; });
|
|
43
43
|
}
|
|
44
44
|
if ((link = form.find('a.period_select_last_month')).length) {
|
|
45
|
-
link.click(function() { InputPeriod.selectPreviousMonth($(this), 1
|
|
45
|
+
link.click(function() { InputPeriod.selectPreviousMonth($(this), 1); return false; });
|
|
46
46
|
}
|
|
47
47
|
if ((link = form.find('a.period_select_current_year')).length) {
|
|
48
|
-
link.click(function() { InputPeriod.selectCurrentYear($(this)
|
|
48
|
+
link.click(function() { InputPeriod.selectCurrentYear($(this)); return false; });
|
|
49
49
|
}
|
|
50
50
|
if ((link = form.find('a.period_select_last_year')).length) {
|
|
51
|
-
link.click(function() { InputPeriod.
|
|
51
|
+
link.click(function() { InputPeriod.selectPreviousYear($(this), 1); return false; });
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
|
|
56
|
-
static selectToday(link
|
|
56
|
+
static selectToday(link) {
|
|
57
57
|
let date = new Date();
|
|
58
|
-
this.selectPeriod(link, date, date
|
|
58
|
+
this.selectPeriod(link, date, date);
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
static selectPreviousDay(lien, nbDays
|
|
62
|
-
this.selectFollowingDay(lien, -nbDays
|
|
61
|
+
static selectPreviousDay(lien, nbDays) {
|
|
62
|
+
this.selectFollowingDay(lien, -nbDays);
|
|
63
63
|
}
|
|
64
|
-
static selectFollowingDay(lien, nbDays
|
|
64
|
+
static selectFollowingDay(lien, nbDays) {
|
|
65
65
|
let date = new Date();
|
|
66
66
|
date.setDate(date.getDate() + nbDays);
|
|
67
|
-
this.selectPeriod(lien, date, date
|
|
67
|
+
this.selectPeriod(lien, date, date);
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
static selectCurrentWeek(lien
|
|
70
|
+
static selectCurrentWeek(lien) {
|
|
71
71
|
let date = new Date();
|
|
72
72
|
this.selectPeriod(lien, DateTime.getFirstDayOfWeek(date), DateTime.getLastDayOfWeek(date));
|
|
73
73
|
}
|
|
74
|
-
static selectPreviousWeek(lien, nbWeeks
|
|
75
|
-
this.selectFollowingWeek(lien, -nbWeeks
|
|
74
|
+
static selectPreviousWeek(lien, nbWeeks) {
|
|
75
|
+
this.selectFollowingWeek(lien, -nbWeeks);
|
|
76
76
|
}
|
|
77
|
-
static selectFollowingWeek(lien, nbWeeks
|
|
77
|
+
static selectFollowingWeek(lien, nbWeeks) {
|
|
78
78
|
let date = new Date();
|
|
79
79
|
date.setDate(date.getDate() + (7*nbWeeks));
|
|
80
|
-
this.selectPeriod(lien, DateTime.getFirstDayOfWeek(date), DateTime.getLastDayOfWeek(date)
|
|
80
|
+
this.selectPeriod(lien, DateTime.getFirstDayOfWeek(date), DateTime.getLastDayOfWeek(date));
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
static selectCurrentMonth(lien
|
|
83
|
+
static selectCurrentMonth(lien) {
|
|
84
84
|
let date = new Date();
|
|
85
|
-
this.selectPeriod(lien, DateTime.getFirstDayOfMonth(date), DateTime.getLastDayOfMonth(date)
|
|
85
|
+
this.selectPeriod(lien, DateTime.getFirstDayOfMonth(date), DateTime.getLastDayOfMonth(date));
|
|
86
86
|
}
|
|
87
|
-
static selectPreviousMonth(lien, nbMonths
|
|
88
|
-
this.selectFollowingMonth(lien, -nbMonths
|
|
87
|
+
static selectPreviousMonth(lien, nbMonths) {
|
|
88
|
+
this.selectFollowingMonth(lien, -nbMonths);
|
|
89
89
|
}
|
|
90
|
-
static selectFollowingMonth(lien, nbMonths
|
|
90
|
+
static selectFollowingMonth(lien, nbMonths) {
|
|
91
91
|
let date = new Date();
|
|
92
92
|
date.setDate(1);
|
|
93
93
|
date.setMonth(date.getMonth() + nbMonths);
|
|
94
|
-
this.selectPeriod(lien, DateTime.getFirstDayOfMonth(date), DateTime.getLastDayOfMonth(date)
|
|
94
|
+
this.selectPeriod(lien, DateTime.getFirstDayOfMonth(date), DateTime.getLastDayOfMonth(date));
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
static selectCurrentYear(lien
|
|
98
|
-
this.selectFollowingYear(lien, 0
|
|
97
|
+
static selectCurrentYear(lien) {
|
|
98
|
+
this.selectFollowingYear(lien, 0);
|
|
99
99
|
}
|
|
100
|
-
static selectPreviousYear(lien, nbAnneesMoins
|
|
101
|
-
this.selectFollowingYear(lien, -nbAnneesMoins
|
|
100
|
+
static selectPreviousYear(lien, nbAnneesMoins) {
|
|
101
|
+
this.selectFollowingYear(lien, -nbAnneesMoins);
|
|
102
102
|
}
|
|
103
|
-
static selectFollowingYear(lien, nbAnneesMoins
|
|
103
|
+
static selectFollowingYear(lien, nbAnneesMoins) {
|
|
104
104
|
let date = new Date();
|
|
105
105
|
date.setFullYear(date.getFullYear() + nbAnneesMoins);
|
|
106
|
-
this.selectPeriod(lien, DateTime.getFirstDayOfYear(date), DateTime.getLastDayOfYear(date)
|
|
106
|
+
this.selectPeriod(lien, DateTime.getFirstDayOfYear(date), DateTime.getLastDayOfYear(date));
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
|
|
110
|
-
static selectPeriod(link, startDate, endDate
|
|
110
|
+
static selectPeriod(link, startDate, endDate) {
|
|
111
111
|
let inputPeriodStart = link.parent().parent().find('input[type="date"]').filter('[name="date_start"], [name="start_date"], [name="start_period"], [name="period_start_date"]');
|
|
112
112
|
let inputPeriodEnd = link.parent().parent().find('input[type="date"]').filter('[name="date_end"], [name="end_date"], [name="end_period"], [name="period_end_date"]');
|
|
113
113
|
if (inputPeriodStart.length === 0 || inputPeriodEnd.length === 0) {
|
|
@@ -115,8 +115,8 @@ class InputPeriod {
|
|
|
115
115
|
return;
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
inputPeriodStart.val(DateTime.getDateForInputDate(startDate
|
|
119
|
-
inputPeriodEnd.val(DateTime.getDateForInputDate(endDate
|
|
118
|
+
inputPeriodStart.val(DateTime.getDateForInputDate(startDate));
|
|
119
|
+
inputPeriodEnd.val(DateTime.getDateForInputDate(endDate));
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
}
|