Merge pull request #1162 from zklosko/moment

Replacing Moment.js with Day.js
This commit is contained in:
Kyle Robbertze 2021-01-19 15:18:19 +02:00 committed by GitHub
commit 9e10d615b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 20 additions and 21 deletions

View File

@ -75,6 +75,11 @@ class ScheduleController extends Zend_Controller_Action
$this->view->headScript()->appendFile($baseUrl.'js/timepicker/jquery.ui.timepicker.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/colorpicker/js/colorpicker.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
// This block needs to be added before the add-show.js script
$this->view->headScript()->appendFile($baseUrl.'js/libs/dayjs.min.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/libs/utc.min.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/libs/timezone.min.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/airtime/schedule/add-show.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->offsetSetFile(100, $baseUrl.'js/airtime/schedule/schedule.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/blockui/jquery.blockUI.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
@ -89,8 +94,6 @@ class ScheduleController extends Zend_Controller_Action
$headScript = $this->view->headScript();
AirtimeTableView::injectTableJavaScriptDependencies($headScript, $baseUrl, $CC_CONFIG['airtime_version']);
$this->view->headScript()->appendFile($baseUrl.'js/libs/moment.min.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/libs/moment-timezone.min.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/airtime/utilities/utilities.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/airtime/buttons/buttons.js?'.$CC_CONFIG['airtime_version'],'text/javascript');

View File

@ -52,7 +52,9 @@ class ShowbuilderController extends Zend_Controller_Action
$this->view->headScript()->appendFile($baseUrl.'js/airtime/showbuilder/main_builder.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
// MEDIA BUILDER
$this->view->headScript()->appendFile($baseUrl.'js/js-timezone-detect/jstz-1.0.4.min.js','text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/libs/dayjs.min.js','text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/libs/utc.min.js','text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/libs/timezone.min.js','text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/airtime/library/spl.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/airtime/library/podcast.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/airtime/library/publish.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');

View File

@ -38,8 +38,10 @@ $(document).ready(function() {
language = language.replace("-", "_");
$("#setup_language").val(language);
var timezone = jstz.determine();
var timezone_name = timezone.name();
dayjs.extend(utc)
dayjs.extend(timezone)
var timezone_name = dayjs.tz.guess();
if (timezone_name === undefined) {
timezone_name = "America/Toronto";
}

View File

@ -4,6 +4,10 @@
*
*/
// Init Day.JS plugins
dayjs.extend(window.dayjs_plugin_utc);
dayjs.extend(window.dayjs_plugin_timezone);
function openAddShowForm(nowOrFuture) {
if($("#add-show-form").length == 1) {
if( ($("#add-show-form").css('display')=='none')) {
@ -63,7 +67,7 @@ function setupStartTimeWidgets() {
var currentTimezone = $("#add_show_timezone").val();
//Set the show start time to now (in the show timezone)
var now = moment(new Date()).tz(currentTimezone);
var now = dayjs(new Date()).tz(currentTimezone);
$('#add_show_start_date').val(now.format('YYYY-MM-DD'));
$('#add_show_start_time').val(now.format('HH:mm'));

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,6 +0,0 @@
//! moment-timezone.js
//! version : 0.4.0
//! author : Tim Wood
//! license : MIT
//! github.com/moment/moment-timezone
!function(a,b){"use strict";"function"==typeof define&&define.amd?define(["moment"],b):"object"==typeof exports?module.exports=b(require("moment")):b(a.moment)}(this,function(a){"use strict";function b(a){return a>96?a-87:a>64?a-29:a-48}function c(a){var c,d=0,e=a.split("."),f=e[0],g=e[1]||"",h=1,i=0,j=1;for(45===a.charCodeAt(0)&&(d=1,j=-1),d;d<f.length;d++)c=b(f.charCodeAt(d)),i=60*i+c;for(d=0;d<g.length;d++)h/=60,c=b(g.charCodeAt(d)),i+=c*h;return i*j}function d(a){for(var b=0;b<a.length;b++)a[b]=c(a[b])}function e(a,b){for(var c=0;b>c;c++)a[c]=Math.round((a[c-1]||0)+6e4*a[c]);a[b-1]=1/0}function f(a,b){var c,d=[];for(c=0;c<b.length;c++)d[c]=a[b[c]];return d}function g(a){var b=a.split("|"),c=b[2].split(" "),g=b[3].split(""),h=b[4].split(" ");return d(c),d(g),d(h),e(h,g.length),{name:b[0],abbrs:f(b[1].split(" "),g),offsets:f(c,g),untils:h}}function h(a){a&&this._set(g(a))}function i(a){return(a||"").toLowerCase().replace(/\//g,"_")}function j(a){var b,c,d;for("string"==typeof a&&(a=[a]),b=0;b<a.length;b++)c=a[b].split("|")[0],d=i(c),v[d]=a[b],x[d]=c}function k(a,b){a=i(a);var c,d=v[a];return d instanceof h?d:"string"==typeof d?(d=new h(d),v[a]=d,d):w[a]&&b!==k&&(c=k(w[a],k))?(d=v[a]=new h,d._set(c),d.name=x[a],d):null}function l(){var a,b=[];for(a in x)x.hasOwnProperty(a)&&(v[a]||v[w[a]])&&x[a]&&b.push(x[a]);return b.sort()}function m(a){var b,c,d,e;for("string"==typeof a&&(a=[a]),b=0;b<a.length;b++)c=a[b].split("|"),d=i(c[0]),e=i(c[1]),w[d]=e,x[d]=c[0],w[e]=d,x[e]=c[1]}function n(a){j(a.zones),m(a.links),r.dataVersion=a.version}function o(a){return o.didShowError||(o.didShowError=!0,q("moment.tz.zoneExists('"+a+"') has been deprecated in favor of !moment.tz.zone('"+a+"')")),!!k(a)}function p(a){return!(!a._a||void 0!==a._tzm)}function q(a){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(a)}function r(b){var c=Array.prototype.slice.call(arguments,0,-1),d=arguments[arguments.length-1],e=k(d),f=a.utc.apply(null,c);return e&&!a.isMoment(b)&&p(f)&&f.add(e.parse(f),"minutes"),f.tz(d),f}function s(a){return function(){return this._z?this._z.abbr(this):a.call(this)}}function t(a){return function(){return this._z=null,a.apply(this,arguments)}}if(void 0!==a.tz)return q("Moment Timezone "+a.tz.version+" was already loaded "+(a.tz.dataVersion?"with data from ":"without any data")+a.tz.dataVersion),a;var u="0.4.0",v={},w={},x={},y=a.version.split("."),z=+y[0],A=+y[1];(2>z||2===z&&6>A)&&q("Moment Timezone requires Moment.js >= 2.6.0. You are using Moment.js "+a.version+". See momentjs.com"),h.prototype={_set:function(a){this.name=a.name,this.abbrs=a.abbrs,this.untils=a.untils,this.offsets=a.offsets},_index:function(a){var b,c=+a,d=this.untils;for(b=0;b<d.length;b++)if(c<d[b])return b},parse:function(a){var b,c,d,e,f=+a,g=this.offsets,h=this.untils,i=h.length-1;for(e=0;i>e;e++)if(b=g[e],c=g[e+1],d=g[e?e-1:e],c>b&&r.moveAmbiguousForward?b=c:b>d&&r.moveInvalidForward&&(b=d),f<h[e]-6e4*b)return g[e];return g[i]},abbr:function(a){return this.abbrs[this._index(a)]},offset:function(a){return this.offsets[this._index(a)]}},r.version=u,r.dataVersion="",r._zones=v,r._links=w,r._names=x,r.add=j,r.link=m,r.load=n,r.zone=k,r.zoneExists=o,r.names=l,r.Zone=h,r.unpack=g,r.unpackBase60=c,r.needsOffset=p,r.moveInvalidForward=!0,r.moveAmbiguousForward=!1;var B=a.fn;a.tz=r,a.defaultZone=null,a.updateOffset=function(b,c){var d,e=a.defaultZone;void 0===b._z&&(e&&p(b)&&!b._isUTC&&(b._d=a.utc(b._a)._d,b.utc().add(e.parse(b),"minutes")),b._z=e),b._z&&(d=b._z.offset(b),Math.abs(d)<16&&(d/=60),void 0!==b.utcOffset?b.utcOffset(-d,c):b.zone(d,c))},B.tz=function(b){return b?(this._z=k(b),this._z?a.updateOffset(this):q("Moment Timezone has no data for "+b+". See http://momentjs.com/timezone/docs/#/data-loading/."),this):this._z?this._z.name:void 0},B.zoneName=s(B.zoneName),B.zoneAbbr=s(B.zoneAbbr),B.utc=t(B.utc),a.tz.setDefault=function(b){return(2>z||2===z&&9>A)&&q("Moment Timezone setDefault() requires Moment.js >= 2.9.0. You are using Moment.js "+a.version+"."),a.defaultZone=b?k(b):null,a};var C=a.momentProperties;return"[object Array]"===Object.prototype.toString.call(C)?(C.push("_z"),C.push("_a")):C&&(C._z=null),a});

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.dayjs_plugin_timezone=e()}(this,function(){"use strict";var m={year:0,month:1,day:2,hour:3,minute:4,second:5},o={};return function(t,e,a){function f(t,i,e){return void 0===e&&(e={}),t=new Date(t),function(t){void 0===t&&(t={});var e=t.timeZoneName||"short",n=i+"|"+e,t=o[n];return t||(t=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:i,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:e}),o[n]=t),t}(e).formatToParts(t)}function r(t,e){for(var n=f(t,e),i=[],o=0;o<n.length;o+=1){var r=n[o],u=r.type,r=r.value,u=m[u];0<=u&&(i[u]=parseInt(r,10))}return e=24===(e=i[3])?0:e,e=i[0]+"-"+i[1]+"-"+i[2]+" "+e+":"+i[4]+":"+i[5]+":000",t=+t,(a.utc(e).valueOf()-(t-=t%1e3))/6e4}var u,s=a().utcOffset(),e=e.prototype;e.tz=function(t,e){void 0===t&&(t=u);var n=this.utcOffset(),i=this.toDate().toLocaleString("en-US",{timeZone:t}),o=Math.round((this.toDate()-new Date(i))/1e3/60),o=a(i).$set("millisecond",this.$ms).utcOffset(s-o,!0);return e&&(e=o.utcOffset(),o=o.add(n-e,"minute")),o.$x.$timezone=t,o},e.offsetName=function(t){var e=this.$x.$timezone||a.tz.guess(),t=f(this.valueOf(),e,{timeZoneName:t}).find(function(t){return"timezonename"===t.type.toLowerCase()});return t&&t.value};var i=e.startOf;e.startOf=function(t,e){if(!this.$x||!this.$x.$timezone)return i.call(this,t,e);var n=a(this.format("YYYY-MM-DD HH:mm:ss:SSS"));return i.call(n,t,e).tz(this.$x.$timezone,!0)},a.tz=function(t,e,n){var i=n&&e,n=n||e||u,e=r(+a(),n);if("string"!=typeof t)return a(t).tz(n);i=function(t,e,n){var i=t-60*e*1e3,o=r(i,n);if(e===o)return[i,e];n=r(i-=60*(o-e)*1e3,n);return o===n?[i,o]:[t-60*Math.min(o,n)*1e3,Math.max(o,n)]}(a.utc(t,i).valueOf(),e,n),e=i[0],i=i[1],i=a(e).utcOffset(i);return i.$x.$timezone=n,i},a.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},a.tz.setDefault=function(t){u=t}}});

1
airtime_mvc/public/js/libs/utc.min.js vendored Normal file
View File

@ -0,0 +1 @@
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i():"function"==typeof define&&define.amd?define(i):t.dayjs_plugin_utc=i()}(this,function(){"use strict";return function(t,i,f){var s=i.prototype;f.utc=function(t){return new i({date:t,utc:!0,args:arguments})},s.utc=function(t){var i=f(this.toDate(),{locale:this.$L,utc:!0});return t?i.add(this.utcOffset(),"minute"):i},s.local=function(){return f(this.toDate(),{locale:this.$L,utc:!1})};var e=s.parse;s.parse=function(t){t.utc&&(this.$u=!0),this.$utils().u(t.$offset)||(this.$offset=t.$offset),e.call(this,t)};var n=s.init;s.init=function(){var t;this.$u?(t=this.$d,this.$y=t.getUTCFullYear(),this.$M=t.getUTCMonth(),this.$D=t.getUTCDate(),this.$W=t.getUTCDay(),this.$H=t.getUTCHours(),this.$m=t.getUTCMinutes(),this.$s=t.getUTCSeconds(),this.$ms=t.getUTCMilliseconds()):n.call(this)};var u=s.utcOffset;s.utcOffset=function(t,i){var s=this.$utils().u;if(s(t))return this.$u?0:s(this.$offset)?u.call(this):this.$offset;var e=Math.abs(t)<=16?60*t:t,s=this;return i?(s.$offset=e,s.$u=0===t):0!==t?(t=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset(),(s=this.local().add(e+t,"minute")).$offset=e,s.$x.$localOffset=t):s=this.utc(),s};var o=s.format;s.format=function(t){t=t||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return o.call(this,t)},s.valueOf=function(){var t=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||(new Date).getTimezoneOffset());return this.$d.valueOf()-6e4*t},s.isUTC=function(){return!!this.$u},s.toISOString=function(){return this.toDate().toISOString()},s.toString=function(){return this.toDate().toUTCString()};var r=s.toDate;s.toDate=function(t){return"s"===t&&this.$offset?f(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():r.call(this)};var a=s.diff;s.diff=function(t,i,s){if(t&&this.$u===t.$u)return a.call(this,t,i,s);var e=this.local(),t=f(t).local();return a.call(e,t,i,s)}}});