define(["exports","./globalize.js"],function(_exports,_globalize){function getDisplayRunningTime(ticks){var parts=[],hours=ticks/36e9,minutes=((hours=Math.floor(hours))&&parts.push(hours),(ticks-=36e9*hours)/6e8),hours=(ticks-=6e8*(minutes=Math.floor(minutes)),parts.push(minutes=minutes<10&&hours?"0"+minutes:minutes),ticks/1e7),hours=Math.floor(hours);return parts.push(hours=hours<10?"0"+hours:hours),parts.join(":")}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0;var toLocaleTimeStringSupportsLocales=function(){try{(new Date).toLocaleTimeString("i")}catch(e){return"RangeError"===e.name}return!1}();var dateFormatters={};function getDateTimeFormatter(locale,options){var key,formatter;return Intl.DateTimeFormat?(key=locale,key=(key=(key=(key=(key=(key=(key=(key=(key+=options.weekday||"null")+(options.year||"null"))+(options.month||"null"))+(options.day||"null"))+(options.hour||"null"))+(options.minute||"null"))+(options.second||"null"))+(options.dateStyle||"null"))+(options.timeStyle||"null"),(formatter=dateFormatters[key])||(console.log("creating DateTimeFormat for "+locale+", with options: "+JSON.stringify(options)),formatter=new Intl.DateTimeFormat(locale,options),dateFormatters[key]=formatter),formatter):null}function toLocaleTimeString(date,options){if(!date)throw new Error("date cannot be null");if(options=options||{},toLocaleTimeStringSupportsLocales){var formatter,currentLocale=_globalize.default.getCurrentDateTimeLocale();if(currentLocale)return(formatter=getDateTimeFormatter(currentLocale,options))?formatter.format(date):date.toLocaleTimeString(currentLocale,options)}return date.toLocaleTimeString()}_exports.default={parseISO8601Date:function(s){return new Date(Date.parse(s))},getDisplayRunningTime:getDisplayRunningTime,toLocaleDateString:function(date,options){if(!date)throw new Error("date cannot be null");if(options=options||{},toLocaleTimeStringSupportsLocales){var currentLocale=_globalize.default.getCurrentDateTimeLocale();if(currentLocale)return(formatter=getDateTimeFormatter(currentLocale,options))?formatter.format(date):date.toLocaleDateString(currentLocale,options)}var formatter=function(options){var i,list=[];for(i in options)list.push({name:i,value:options[i]});return list}(options);return 1===formatter.length&&"weekday"===formatter[0].name?(currentLocale=[],"long"===formatter[0].value?(currentLocale[0]="Sunday",currentLocale[1]="Monday",currentLocale[2]="Tuesday",currentLocale[3]="Wednesday",currentLocale[4]="Thursday",currentLocale[5]="Friday",currentLocale[6]="Saturday"):(currentLocale[0]="Sun",currentLocale[1]="Mon",currentLocale[2]="Tue",currentLocale[3]="Wed",currentLocale[4]="Thu",currentLocale[5]="Fri",currentLocale[6]="Sat"),currentLocale[date.getDay()]):date.toLocaleDateString()},toLocaleString:function(date,options){if(!date)throw new Error("date cannot be null");if(options=options||{dateStyle:"short",timeStyle:"short"},toLocaleTimeStringSupportsLocales){var formatter,currentLocale=_globalize.default.getCurrentDateTimeLocale();if(currentLocale)return(formatter=getDateTimeFormatter(currentLocale,options))?formatter.format(date):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=new Date(Date.parse(date))}catch(err){return date}var time,suffix,timeLower;return toLocaleTimeStringSupportsLocales?toLocaleTimeString(date,{hour:"numeric",minute:"2-digit"}):((timeLower=(time=toLocaleTimeString(date)).toLowerCase()).includes("am")||timeLower.includes("pm")?(time=timeLower,timeLower=date.getHours()%12,suffix=11<date.getHours()?"pm":"am",time=(timeLower=timeLower||12)+(timeLower=":"+(timeLower=(timeLower=date.getMinutes())<10?"0"+timeLower:timeLower))+suffix):2<(date=time.split(":")).length&&(date.length=2,time=date.join(":")),time)},isRelativeDay:function(date,offsetInDays){var yesterday;if(date)return offsetInDays=(yesterday=new Date).getDate()+offsetInDays,yesterday.setDate(offsetInDays),date.getFullYear()===yesterday.getFullYear()&&date.getMonth()===yesterday.getMonth()&&date.getDate()===offsetInDays;throw new Error("date cannot be null")},toLocaleTimeString:toLocaleTimeString,supportsLocalization:function(){return toLocaleTimeStringSupportsLocales},getHumanReadableRuntime:function(ticks){try{var days=Math.trunc(ticks/864e9),hours=Math.trunc(ticks%864e9/36e9),mins=Math.trunc(ticks%36e9/6e8),parts=[];return(days&&parts.push(days+"d"),hours&&parts.push(hours+"h"),mins&&parts.push(mins+"m"),parts.length)?parts.join(" "):getDisplayRunningTime(ticks)}catch(err){return getDisplayRunningTime(ticks)}}}});