View | Details | Raw Unified | Return to bug 30310
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/js-date-format.inc (-6 / +14 lines)
Lines 2-9 Link Here
2
[% USE raw %]
2
[% USE raw %]
3
[% USE Asset %]
3
[% USE Asset %]
4
[% USE KohaDates %]
4
[% USE KohaDates %]
5
[% Asset.js("lib/moment/moment.min.js") | $raw %]
5
[% Asset.js("lib/dayjs/dayjs.min.js") | $raw %]
6
[% Asset.js("lib/moment/moment-timezone-with-data-10-year-range.min.js") | $raw %]
6
[% Asset.js("lib/dayjs/plugin/timezone.js") | $raw %]
7
[% Asset.js("lib/dayjs/plugin/utc.js") | $raw %]
8
<script>
9
    dayjs.extend(window.dayjs_plugin_utc);
10
    dayjs.extend(window.dayjs_plugin_timezone);
11
</script>
12
7
<!-- js-date-format.inc -->
13
<!-- js-date-format.inc -->
8
<script>
14
<script>
9
    (function() {
15
    (function() {
Lines 34-41 Link Here
34
        window.$date = function(value, options) {
40
        window.$date = function(value, options) {
35
            if(!value) return '';
41
            if(!value) return '';
36
            var tz = (options&&options.tz)||def_tz;
42
            var tz = (options&&options.tz)||def_tz;
37
            var m = moment(value);
43
            var m = dayjs(value);
38
            if((m.creationData().format !== 'YYYY-MM-DD')&&tz) m.tz(tz);
44
            if ( ! value.match(/^\d{4}-\d{2}-\d{2}$/ ) ) {
45
                m = m.tz(tz);
46
            }
39
47
40
            var dateformat = (options&&options.dateformat)||def_date_format;
48
            var dateformat = (options&&options.dateformat)||def_date_format;
41
            var withtime = (options&&options.withtime)||false;
49
            var withtime = (options&&options.withtime)||false;
Lines 58-65 Link Here
58
        window.$time = function(value, options) {
66
        window.$time = function(value, options) {
59
            if(!value) return '';
67
            if(!value) return '';
60
            var tz = (options&&options.tz)||def_tz;
68
            var tz = (options&&options.tz)||def_tz;
61
            var m = moment(value);
69
            var m = dayjs(value);
62
            if(tz) m.tz(tz);
70
            if(tz) m = m.tz(tz);
63
71
64
            var dateformat = (options&&options.dateformat);
72
            var dateformat = (options&&options.dateformat);
65
            var timeformat = (dateformat=='rfc3339'&&'24hr')||(options&&options.timeformat)||def_time_format;
73
            var timeformat = (dateformat=='rfc3339'&&'24hr')||(options&&options.timeformat)||def_time_format;
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/js-date-format.inc (-8 / +17 lines)
Lines 2-9 Link Here
2
[% USE raw %]
2
[% USE raw %]
3
[% USE Asset %]
3
[% USE Asset %]
4
[% USE KohaDates %]
4
[% USE KohaDates %]
5
[% Asset.js("lib/moment.min.js") | $raw %]
5
[% Asset.js("lib/dayjs/dayjs.min.js") | $raw %]
6
[% Asset.js("lib/moment-timezone-with-data-10-year-range.min.js") | $raw %]
6
[% Asset.js("lib/dayjs/plugin/timezone.js") | $raw %]
7
[% Asset.js("lib/dayjs/plugin/utc.js") | $raw %]
8
<script>
9
    dayjs.extend(window.dayjs_plugin_utc);
10
    dayjs.extend(window.dayjs_plugin_timezone);
11
</script>
12
13
<!-- js-date-format.inc -->
7
<script>
14
<script>
8
    (function() {
15
    (function() {
9
        var def_date_format = '[% Koha.Preference('dateformat') | html %]';
16
        var def_date_format = '[% Koha.Preference('dateformat') | html %]';
Lines 33-40 Link Here
33
        window.$date = function(value, options) {
40
        window.$date = function(value, options) {
34
            if(!value) return '';
41
            if(!value) return '';
35
            var tz = (options&&options.tz)||def_tz;
42
            var tz = (options&&options.tz)||def_tz;
36
            var m = moment(value);
43
            var m = dayjs(value);
37
            if((m.creationData().format !== 'YYYY-MM-DD')&&tz) m.tz(tz);
44
            if ( ! value.match(/^\d{4}-\d{2}-\d{2}$/ ) ) {
45
                m = m.tz(tz);
46
            }
38
47
39
            var dateformat = (options&&options.dateformat)||def_date_format;
48
            var dateformat = (options&&options.dateformat)||def_date_format;
40
            var withtime = (options&&options.withtime)||false;
49
            var withtime = (options&&options.withtime)||false;
Lines 56-64 Link Here
56
65
57
        window.$time = function(value, options) {
66
        window.$time = function(value, options) {
58
            if(!value) return '';
67
            if(!value) return '';
59
            var tz = (opitons&&options.tz)||def_tz;
68
            var tz = (options&&options.tz)||def_tz;
60
            var m = moment(value);
69
            var m = dayjs(value);
61
            if(tz) m.tz(tz);
70
            if(tz) m = m.tz(tz);
62
71
63
            var dateformat = (options&&options.dateformat);
72
            var dateformat = (options&&options.dateformat);
64
            var timeformat = (dateformat=='rfc3339'&&'24hr')||(options&&options.timeformat)||def_time_format;
73
            var timeformat = (dateformat=='rfc3339'&&'24hr')||(options&&options.timeformat)||def_time_format;
Lines 68-70 Link Here
68
77
69
    })();
78
    })();
70
</script>
79
</script>
71
- 
80
<!-- / js-date-format.inc -->

Return to bug 30310