From df9861f24f43f8c6ec4e7e337227a938f41d8411 Mon Sep 17 00:00:00 2001 From: taylorhakes Date: Fri, 7 Aug 2015 21:19:20 -0400 Subject: [PATCH] Fixed a bug in amd definition --- bower.json | 2 +- fecha.js | 2 +- fecha.min.js | 2 +- package.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bower.json b/bower.json index 818f9db..314ce6a 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "fecha", "main": "fecha.js", - "version": "0.2.1", + "version": "0.2.2", "homepage": "https://github.com/taylorhakes/fecha", "authors": [ "Taylor Hakes" diff --git a/fecha.js b/fecha.js index 66badaf..2113a45 100644 --- a/fecha.js +++ b/fecha.js @@ -253,7 +253,7 @@ if (typeof module !== 'undefined' && module.exports) { module.exports = fecha; - } else if (typeof require !== 'undefined' && require.amd) { + } else if (typeof define === 'function' && define.amd) { define(function () { return fecha; }); diff --git a/fecha.min.js b/fecha.min.js index a6cb7d9..e0d521a 100644 --- a/fecha.min.js +++ b/fecha.min.js @@ -1 +1 @@ -!function(e){"use strict";function n(e){return function(n,t){var a=o.i18n[e].indexOf(t.charAt(0).toUpperCase()+t.substr(1).toLowerCase());~a&&(n.month=a)}}function t(e,n){for(e=String(e),n=n||2;e.lengtha;a++)n.push(e[a].substr(0,t))}function r(e){return e+["th","st","nd","rd"][e%10>3?0:(e-e%10!==10)*e%10]}var o={},u=/d{1,4}|M{1,4}|YY(?:YY)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g,s=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],d=["January","February","March","April","May","June","July","August","September","October","November","December"],i=["am","pm"],m=/\d\d?/,h=/\d{3}/,c=/\d{4}/,f=/[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i,M=function(){},l=[],Y=[],D={D:[m,function(e,n){e.day=n}],M:[m,function(e,n){e.month=n-1}],YY:[m,function(e,n){var t=new Date,a=+(""+t.getFullYear()).substr(0,2);e.year=""+(n>68?a-1:a)+n}],h:[m,function(e,n){e.hour=n}],m:[m,function(e,n){e.minute=n}],s:[m,function(e,n){e.second=n}],YYYY:[c,function(e,n){e.year=n}],S:[/\d/,function(e,n){e.millisecond=100*n}],SS:[/\d{2}/,function(e,n){e.millisecond=10*n}],SSS:[h,function(e,n){e.millisecond=n}],d:[m,M],ddd:[f,M],MMM:[f,n("monthNamesShort")],MMMM:[f,n("monthNames")],a:[f,function(e,n){i.indexOf(n.toLowerCase())&&(e.isPm=!0)}],ZZ:[/[\+\-]\d\d:?\d\d/,function(e,n){var t,a=(n+"").match(/([\+\-]|\d\d)/gi);a&&(t=+(60*a[1])+parseInt(a[2],10),e.timezoneOffset="+"===a[0]?t:-t)}]};D.dd=D.d,D.dddd=D.ddd,D.Do=D.DD=D.D,D.mm=D.m,D.hh=D.H=D.HH=D.h,D.MM=D.M,D.ss=D.s,D.A=D.a,a(d,Y,3),a(s,l,3),o.i18n={dayNamesShort:l,dayNames:s,monthNamesShort:Y,monthNames:d,amPm:i,DoFn:r},o.masks={"default":"ddd MMM DD YYYY HH:mm:ss",shortDate:"M/D/YY",mediumDate:"MMM D, YYYY",longDate:"MMMM D, YYYY",fullDate:"dddd, MMMM D, YYYY",shortTime:"HH:mm",mediumTime:"HH:mm:ss",longTime:"HH:mm:ss.SSS"},o.format=function(e,n){if("string"==typeof e?e=o.parse(e):e||(e=new Date),isNaN(e))throw new SyntaxError("invalid date");n=o.masks[n]||n||o.masks["default"];var a=e.getDate(),r=e.getDay(),s=e.getMonth(),d=e.getFullYear(),i=e.getHours(),m=e.getMinutes(),h=e.getSeconds(),c=e.getMilliseconds(),f=e.getTimezoneOffset(),M={D:a,DD:t(a),Do:o.i18n.DoFn(a),d:r,dd:t(r),ddd:o.i18n.dayNamesShort[r],dddd:o.i18n.dayNames[r],M:s+1,MM:t(s+1),MMM:o.i18n.monthNamesShort[s],MMMM:o.i18n.monthNames[s],YY:String(d).slice(2),YYYY:d,h:i%12||12,hh:t(i%12||12),H:i,HH:t(i),m:m,mm:t(m),s:h,ss:t(h),S:Math.round(c/100),SS:t(Math.round(c/10),2),SSS:t(c,3),a:12>i?o.i18n.amPm[0]:o.i18n.amPm[1],A:12>i?o.i18n.amPm[0].toUpperCase():o.i18n.amPm[1].toUpperCase(),ZZ:(f>0?"-":"+")+t(100*Math.floor(Math.abs(f)/60)+Math.abs(f)%60,4)};return n.replace(u,function(e){return e in M?M[e]:e.slice(1,e.length-1)})},o.parse=function(e,n){var t,a,r,s,d,i,m;return n?(n=o.masks[n]||n,a=!0,r={},n.replace(u,function(n){return D[n]&&(i=D[n],m=e.search(i[0]),~m?e.replace(i[0],function(n){return i[1](r,n),e=e.substr(m+n.length),n}):a=!1),D[n]?"":n.slice(1,n.length-1)}),a?(s=new Date,r.isPm&&r.hour&&(r.hour=+r.hour+12),r.timezoneOffset?(r.minute=+(r.minute||0)-+r.timezoneOffset,d=new Date(Date.UTC(r.year||s.getFullYear(),r.month||0,r.day||1,r.hour||0,r.minute||0,r.second||0,r.millisecond||0))):d=new Date(r.year||s.getFullYear(),r.month||0,r.day||1,r.hour||0,r.minute||0,r.second||0,r.millisecond||0),d):!1):(t=Date.parse(e.replace(/\-/g,"/")),isNaN(t)?!1:new Date(t))},"undefined"!=typeof module&&module.exports?module.exports=o:"undefined"!=typeof require&&require.amd?define(function(){return o}):e.fecha=o}(this); \ No newline at end of file +!function(e){"use strict";function n(e){return function(n,t){var a=r.i18n[e].indexOf(t.charAt(0).toUpperCase()+t.substr(1).toLowerCase());~a&&(n.month=a)}}function t(e,n){for(e=String(e),n=n||2;e.lengtha;a++)n.push(e[a].substr(0,t))}function o(e){return e+["th","st","nd","rd"][e%10>3?0:(e-e%10!==10)*e%10]}var r={},s=/d{1,4}|M{1,4}|YY(?:YY)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g,u=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],d=["January","February","March","April","May","June","July","August","September","October","November","December"],i=["am","pm"],m=/\d\d?/,f=/\d{3}/,h=/\d{4}/,c=/[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i,M=function(){},l=[],Y=[],D={D:[m,function(e,n){e.day=n}],M:[m,function(e,n){e.month=n-1}],YY:[m,function(e,n){var t=new Date,a=+(""+t.getFullYear()).substr(0,2);e.year=""+(n>68?a-1:a)+n}],h:[m,function(e,n){e.hour=n}],m:[m,function(e,n){e.minute=n}],s:[m,function(e,n){e.second=n}],YYYY:[h,function(e,n){e.year=n}],S:[/\d/,function(e,n){e.millisecond=100*n}],SS:[/\d{2}/,function(e,n){e.millisecond=10*n}],SSS:[f,function(e,n){e.millisecond=n}],d:[m,M],ddd:[c,M],MMM:[c,n("monthNamesShort")],MMMM:[c,n("monthNames")],a:[c,function(e,n){i.indexOf(n.toLowerCase())&&(e.isPm=!0)}],ZZ:[/[\+\-]\d\d:?\d\d/,function(e,n){var t,a=(n+"").match(/([\+\-]|\d\d)/gi);a&&(t=+(60*a[1])+parseInt(a[2],10),e.timezoneOffset="+"===a[0]?t:-t)}]};D.dd=D.d,D.dddd=D.ddd,D.Do=D.DD=D.D,D.mm=D.m,D.hh=D.H=D.HH=D.h,D.MM=D.M,D.ss=D.s,D.A=D.a,a(d,Y,3),a(u,l,3),r.i18n={dayNamesShort:l,dayNames:u,monthNamesShort:Y,monthNames:d,amPm:i,DoFn:o},r.masks={"default":"ddd MMM DD YYYY HH:mm:ss",shortDate:"M/D/YY",mediumDate:"MMM D, YYYY",longDate:"MMMM D, YYYY",fullDate:"dddd, MMMM D, YYYY",shortTime:"HH:mm",mediumTime:"HH:mm:ss",longTime:"HH:mm:ss.SSS"},r.format=function(e,n){if("string"==typeof e?e=r.parse(e):e||(e=new Date),isNaN(e))throw new SyntaxError("invalid date");n=r.masks[n]||n||r.masks["default"];var a=e.getDate(),o=e.getDay(),u=e.getMonth(),d=e.getFullYear(),i=e.getHours(),m=e.getMinutes(),f=e.getSeconds(),h=e.getMilliseconds(),c=e.getTimezoneOffset(),M={D:a,DD:t(a),Do:r.i18n.DoFn(a),d:o,dd:t(o),ddd:r.i18n.dayNamesShort[o],dddd:r.i18n.dayNames[o],M:u+1,MM:t(u+1),MMM:r.i18n.monthNamesShort[u],MMMM:r.i18n.monthNames[u],YY:String(d).slice(2),YYYY:d,h:i%12||12,hh:t(i%12||12),H:i,HH:t(i),m:m,mm:t(m),s:f,ss:t(f),S:Math.round(h/100),SS:t(Math.round(h/10),2),SSS:t(h,3),a:12>i?r.i18n.amPm[0]:r.i18n.amPm[1],A:12>i?r.i18n.amPm[0].toUpperCase():r.i18n.amPm[1].toUpperCase(),ZZ:(c>0?"-":"+")+t(100*Math.floor(Math.abs(c)/60)+Math.abs(c)%60,4)};return n.replace(s,function(e){return e in M?M[e]:e.slice(1,e.length-1)})},r.parse=function(e,n){var t,a,o,u,d,i,m;return n?(n=r.masks[n]||n,a=!0,o={},n.replace(s,function(n){return D[n]&&(i=D[n],m=e.search(i[0]),~m?e.replace(i[0],function(n){return i[1](o,n),e=e.substr(m+n.length),n}):a=!1),D[n]?"":n.slice(1,n.length-1)}),a?(u=new Date,o.isPm&&o.hour&&(o.hour=+o.hour+12),o.timezoneOffset?(o.minute=+(o.minute||0)-+o.timezoneOffset,d=new Date(Date.UTC(o.year||u.getFullYear(),o.month||0,o.day||1,o.hour||0,o.minute||0,o.second||0,o.millisecond||0))):d=new Date(o.year||u.getFullYear(),o.month||0,o.day||1,o.hour||0,o.minute||0,o.second||0,o.millisecond||0),d):!1):(t=Date.parse(e.replace(/\-/g,"/")),isNaN(t)?!1:new Date(t))},"undefined"!=typeof module&&module.exports?module.exports=r:"function"==typeof define&&define.amd?define(function(){return r}):e.fecha=r}(this); \ No newline at end of file diff --git a/package.json b/package.json index 7620b21..39abc82 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fecha", - "version": "0.2.1", + "version": "0.2.2", "description": "Date formatting and parsing", "main": "fecha.js", "scripts": {