define(["globalize"],function(globalize){"use strict";function parseISO8601Date(s,toLocal){if(Date.parse)return new Date(Date.parse(s));var d=s.match(/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(\.\d+)?(Z|([+-])(\d{2}):(\d{2}))?/);if(!d)throw"Couldn't parse ISO 8601 date string '"+s+"'";var a=[1,2,3,4,5,6,10,11];for(var i in a)d[a[i]]=parseInt(d[a[i]],10);d[7]=parseFloat(d[7]);var offset,ms=Date.UTC(d[1],d[2]-1,d[3],d[4],d[5],d[6]);return 0<d[7]&&(ms+=Math.round(1e3*d[7])),"Z"!==d[8]&&d[10]?(offset=60*d[10]*60*1e3,d[11]&&(offset+=60*d[11]*1e3),"-"===d[9]?ms-=offset:ms+=offset):!1===toLocal&&(ms+=6e4*(new Date).getTimezoneOffset()),new Date(ms)}var toLocaleTimeStringSupportsLocales=function(){try{(new Date).toLocaleTimeString("i")}catch(e){return"RangeError"===e.name}return!1}();function toLocaleTimeString(date,options){if(!date)throw new Error("date cannot be null");if(options=options||{},toLocaleTimeStringSupportsLocales){var currentLocale=globalize.getCurrentDateTimeLocale();if(currentLocale)return date.toLocaleTimeString(currentLocale,options)}return date.toLocaleTimeString()}return{parseISO8601Date:parseISO8601Date,getDisplayRunningTime:function(ticks){var parts=[],hours=ticks/36e9;(hours=Math.floor(hours))&&parts.push(hours);var minutes=(ticks-=36e9*hours)/6e8;ticks-=6e8*(minutes=Math.floor(minutes)),minutes<10&&hours&&(minutes="0"+minutes),parts.push(minutes);var seconds=ticks/1e7;return(seconds=Math.floor(seconds))<10&&(seconds="0"+seconds),parts.push(seconds),parts.join(":")},toLocaleDateString:function(date,options){if(!date)throw new Error("date cannot be null");if(options=options||{},toLocaleTimeStringSupportsLocales){var currentLocale=globalize.getCurrentDateTimeLocale();if(currentLocale)return date.toLocaleDateString(currentLocale,options)}var optionList=function(options){var list=[];for(var i in options)list.push({name:i,value:options[i]});return list}(options);if(1!==optionList.length||"weekday"!==optionList[0].name)return date.toLocaleDateString();var weekday=[];return"long"===optionList[0].value?(weekday[0]="Sunday",weekday[1]="Monday",weekday[2]="Tuesday",weekday[3]="Wednesday",weekday[4]="Thursday",weekday[5]="Friday",weekday[6]="Saturday"):(weekday[0]="Sun",weekday[1]="Mon",weekday[2]="Tue",weekday[3]="Wed",weekday[4]="Thu",weekday[5]="Fri",weekday[6]="Sat"),weekday[date.getDay()]},toLocaleString:function(date,options){if(!date)throw new Error("date cannot be null");if(options=options||{},toLocaleTimeStringSupportsLocales){var currentLocale=globalize.getCurrentDateTimeLocale();if(currentLocale)return date.toLocaleString(currentLocale,options)}return date.toLocaleString()},getDisplayTime:function(date){if(!date)throw new Error("date cannot be null");if("string"===(typeof date).toString().toLowerCase())try{date=parseISO8601Date(date,!0)}catch(err){return date}if(toLocaleTimeStringSupportsLocales)return toLocaleTimeString(date,{hour:"numeric",minute:"2-digit"});var suffix,hour,minutes,timeParts,time=toLocaleTimeString(date),timeLower=time.toLowerCase();return timeLower.includes("am")||timeLower.includes("pm")?(time=timeLower,hour=date.getHours()%12,suffix=11<date.getHours()?"pm":"am",hour=hour||12,(minutes=date.getMinutes())<10&&(minutes="0"+minutes),time=hour+(minutes=":"+minutes)+suffix):2<(timeParts=time.split(":")).length&&(timeParts.length=2,time=timeParts.join(":")),time},isRelativeDay:function(date,offsetInDays){if(!date)throw new Error("date cannot be null");var yesterday=new Date,day=yesterday.getDate()+offsetInDays;return yesterday.setDate(day),date.getFullYear()===yesterday.getFullYear()&&date.getMonth()===yesterday.getMonth()&&date.getDate()===day},toLocaleTimeString:toLocaleTimeString,supportsLocalization:function(){return toLocaleTimeStringSupportsLocales}}});