mirror of
https://github.com/wahyd4/cdnjs.git
synced 2026-08-15 07:46:06 +10:00
9 lines
2.8 KiB
JavaScript
9 lines
2.8 KiB
JavaScript
/**
|
|
* angular-strap
|
|
* @version v2.1.0 - 2014-09-05
|
|
* @link http://mgcrea.github.io/angular-strap
|
|
* @author Olivier Louvignes (olivier@mg-crea.com)
|
|
* @license MIT License, http://www.opensource.org/licenses/MIT
|
|
*/
|
|
"use strict";angular.module("mgcrea.ngStrap.helpers.dateParser",[]).provider("$dateParser",["$localeProvider",function(){function t(){}var e=Date.prototype,r=this.defaults={format:"shortDate",strict:!1};this.$get=["$locale","dateFilter",function(s,n){var i=function(i){function a(t){var e,r=Object.keys(E),s=[],n=[],i=t;for(e=0;e<r.length;e++)if(t.split(r[e]).length>1){var a=i.search(r[e]);t=t.split(r[e]).join(""),E[r[e]]&&(s[a]=E[r[e]])}return angular.forEach(s,function(t){t&&n.push(t)}),n}function o(t){return t.replace(/\//g,"[\\/]").replace("/-/g","[-]").replace(/\./g,"[.]").replace(/\\s/g,"[\\s]")}function u(t){var e,r=Object.keys(h),s=t;for(e=0;e<r.length;e++)s=s.split(r[e]).join("${"+e+"}");for(e=0;e<r.length;e++)s=s.split("${"+e+"}").join("("+h[r[e]]+")");return t=o(t),new RegExp("^"+s+"$",["i"])}var M,c,l=angular.extend({},r,i),f={},h={sss:"[0-9]{3}",ss:"[0-5][0-9]",s:l.strict?"[1-5]?[0-9]":"[0-9]|[0-5][0-9]",mm:"[0-5][0-9]",m:l.strict?"[1-5]?[0-9]":"[0-9]|[0-5][0-9]",HH:"[01][0-9]|2[0-3]",H:l.strict?"1?[0-9]|2[0-3]":"[01]?[0-9]|2[0-3]",hh:"[0][1-9]|[1][012]",h:l.strict?"[1-9]|1[012]":"0?[1-9]|1[012]",a:"AM|PM",EEEE:s.DATETIME_FORMATS.DAY.join("|"),EEE:s.DATETIME_FORMATS.SHORTDAY.join("|"),dd:"0[1-9]|[12][0-9]|3[01]",d:l.strict?"[1-9]|[1-2][0-9]|3[01]":"0?[1-9]|[1-2][0-9]|3[01]",MMMM:s.DATETIME_FORMATS.MONTH.join("|"),MMM:s.DATETIME_FORMATS.SHORTMONTH.join("|"),MM:"0[1-9]|1[012]",M:l.strict?"[1-9]|1[012]":"0?[1-9]|1[012]",yyyy:"[1]{1}[0-9]{3}|[2]{1}[0-9]{3}",yy:"[0-9]{2}",y:l.strict?"-?(0|[1-9][0-9]{0,3})":"-?0*[0-9]{1,4}"},E={sss:e.setMilliseconds,ss:e.setSeconds,s:e.setSeconds,mm:e.setMinutes,m:e.setMinutes,HH:e.setHours,H:e.setHours,hh:e.setHours,h:e.setHours,EEEE:t,EEE:t,dd:e.setDate,d:e.setDate,a:function(t){var e=this.getHours();return this.setHours(t.match(/pm/i)?e+12:e)},MMMM:function(t){return this.setMonth(s.DATETIME_FORMATS.MONTH.indexOf(t))},MMM:function(t){return this.setMonth(s.DATETIME_FORMATS.SHORTMONTH.indexOf(t))},MM:function(t){return this.setMonth(1*t-1)},M:function(t){return this.setMonth(1*t-1)},yyyy:e.setFullYear,yy:function(t){return this.setFullYear(2e3+1*t)},y:e.setFullYear};return f.init=function(){f.$format=s.DATETIME_FORMATS[l.format]||l.format,M=u(f.$format),c=a(f.$format)},f.isValid=function(t){return angular.isDate(t)?!isNaN(t.getTime()):M.test(t)},f.parse=function(t,e,r){angular.isDate(t)&&(t=n(t,r||f.$format));var s=r?u(r):M,i=r?a(r):c,o=s.exec(t);if(!o)return!1;for(var l=e||new Date(0,0,1),h=0;h<o.length-1;h++)i[h]&&i[h].call(l,o[h+1]);return l},f.init(),f};return i}]}]);
|
|
//# sourceMappingURL=date-parser.min.js.map
|