MDL-68200 core: Add calendartype param to user_date.loadDatesFromServer

This commit is contained in:
Shamim Rezaie 2020-04-08 21:25:17 +10:00
parent 4f9bcde969
commit 127f69d3fe
3 changed files with 8 additions and 5 deletions

View File

@ -1,2 +1,2 @@
define ("core/user_date",["jquery","core/ajax","core/sessionstorage","core/config"],function(a,b,c,d){var e={},f=function(b){var c=a("html").attr("lang").replace(/-/g,"_");return"core_user_date/"+c+"/"+d.usertimezone+"/"+b.timestamp+"/"+b.format},g=function(a){return c.get(a)},h=function(a,b){c.set(a,b)},i=function(a){return"undefined"!=typeof e[a]},j=function(a){return e[a]},k=function(a,b){e[a]=b},l=function(a){var c=a.map(function(a){return{timestamp:a.timestamp,format:a.format}}),e={methodname:"core_get_user_dates",args:{contextid:d.contextid,timestamps:c}};return b.call([e],!0,!0)[0].then(function(b){b.dates.forEach(function(b,c){var d=a[c],e=f(d);h(e,b);d.deferred.resolve(b)})}).catch(function(b){a.forEach(function(a){a.deferred.reject(b)})})};return{get:function get(b){var c=[],d=[];b.forEach(function(b){var e=f(b);if(i(e)){d.push(j(e))}else{var h=a.Deferred(),l=g(e);if(l){h.resolve(l)}else{b.deferred=h;c.push(b)}k(e,h.promise());d.push(h.promise())}});if(c.length){l(c)}return a.when.apply(a,d).then(function(){return 1===arguments.length?[arguments[0]]:Array.apply(null,arguments)})},getUserMidnightForTimestamp:function getUserMidnightForTimestamp(a,b){var c=a>b,d=Math.abs(a-b),e=c?Math.floor(d/86400):Math.ceil(d/86400),f=e*86400,g=c?b+f:b-f;return g}}});
define ("core/user_date",["jquery","core/ajax","core/sessionstorage","core/config"],function(a,b,c,d){var e={},f=function(b){var c=a("html").attr("lang").replace(/-/g,"_");return"core_user_date/"+c+"/"+d.usertimezone+"/"+b.timestamp+"/"+b.format},g=function(a){return c.get(a)},h=function(a,b){c.set(a,b)},i=function(a){return"undefined"!=typeof e[a]},j=function(a){return e[a]},k=function(a,b){e[a]=b},l=function(a){var c=a.map(function(a){return{timestamp:a.timestamp,format:a.format,type:a.type||""}}),e={methodname:"core_get_user_dates",args:{contextid:d.contextid,timestamps:c}};return b.call([e],!0,!0)[0].then(function(b){b.dates.forEach(function(b,c){var d=a[c],e=f(d);h(e,b);d.deferred.resolve(b)})}).catch(function(b){a.forEach(function(a){a.deferred.reject(b)})})};return{get:function get(b){var c=[],d=[];b.forEach(function(b){var e=f(b);if(i(e)){d.push(j(e))}else{var h=a.Deferred(),l=g(e);if(l){h.resolve(l)}else{b.deferred=h;c.push(b)}k(e,h.promise());d.push(h.promise())}});if(c.length){l(c)}return a.when.apply(a,d).then(function(){return 1===arguments.length?[arguments[0]]:Array.apply(null,arguments)})},getUserMidnightForTimestamp:function getUserMidnightForTimestamp(a,b){var c=a>b,d=Math.abs(a-b),e=c?Math.floor(d/86400):Math.ceil(d/86400),f=e*86400,g=c?b+f:b-f;return g}}});
//# sourceMappingURL=user_date.min.js.map

File diff suppressed because one or more lines are too long

View File

@ -109,7 +109,8 @@ define(['jquery', 'core/ajax', 'core/sessionstorage', 'core/config'],
var args = dates.map(function(data) {
return {
timestamp: data.timestamp,
format: data.format
format: data.format,
type: data.type || ''
};
});
@ -155,7 +156,8 @@ define(['jquery', 'core/ajax', 'core/sessionstorage', 'core/config'],
* Only dates not found in either cache will be sent to the server
* for transforming.
*
* A request object must have a timestamp key and a format key.
* A request object must have a timestamp key and a format key and
* optionally may have a type key.
*
* E.g.
* var request = [
@ -165,7 +167,8 @@ define(['jquery', 'core/ajax', 'core/sessionstorage', 'core/config'],
* },
* {
* timestamp: 1293876000,
* format: '%A, %d %B %Y, %I:%M %p'
* format: '%A, %d %B %Y, %I:%M %p',
* type: 'gregorian'
* }
* ];
*