define(["exports","./globalize.js"],function(_exports,_globalize){function getDisplayRunningTime(ticks){var duration={},hours=ticks/36e9,hours=((hours=Math.floor(hours))&&(duration.hours=hours),(ticks-=36e9*hours)/6e8),hours=(ticks-=6e8*(hours=Math.floor(hours)),duration.minutes=hours,ticks/1e7),hours=Math.floor(hours);duration.seconds=hours;ticks=getDurationFormatter(_globalize.default.getCurrentLocale(),{style:"digital",fractionalDigits:0,hoursDisplay:"auto",minutesDisplay:"always",secondsDisplay:"always",millisecondsDisplay:"auto",microsecondsDisplay:"auto",nanosecondsDisplay:"auto"}).format(duration);return ticks=ticks.startsWith("0")?ticks.substring(1):ticks}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}(),dateTimeFormatters={};function getDateTimeFormatter(locale,options){var key=locale||"und",formatter=(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"),dateTimeFormatters[key]);return formatter||(console.log("creating DateTimeFormat for "+locale+", with options: "+JSON.stringify(options)),formatter=new Intl.DateTimeFormat(locale,options),dateTimeFormatters[key]=formatter),formatter}var durationFormatters={};function getDurationFormatter(locale,options){var key=locale||"und",formatter=(key=(key=(key=(key=(key=(key=(key=(key+=options.style||"style")+(options.fractionalDigits||"fractionalDigits"))+(options.hoursDisplay||"hoursDisplay"))+(options.minutesDisplay||"minutesDisplay"))+(options.secondsDisplay||"secondsDisplay"))+(options.millisecondsDisplay||"millisecondsDisplay"))+(options.microsecondsDisplay||"microsecondsDisplay"))+(options.nanosecondsDisplay||"nanosecondsDisplay"),durationFormatters[key]);return formatter||(console.log("creating DurationFormat for "+locale+", with options: "+JSON.stringify(options)),formatter=new Intl.DurationFormat(locale,options),durationFormatters[key]=formatter),formatter}function toLocaleTimeString(date,options){if(date)return options=options||{},getDateTimeFormatter(_globalize.default.getCurrentDateTimeLocale(),options).format(date);throw new Error("date cannot be null")}_exports.default={parseISO8601Date:function(s){return new Date(Date.parse(s))},getDisplayRunningTime:getDisplayRunningTime,toLocaleDateString:function(date,options){if(date)return options=options||{},getDateTimeFormatter(_globalize.default.getCurrentDateTimeLocale(),options).format(date);throw new Error("date cannot be null")},toLocaleString:function(date,options){if(date)return options=options||{dateStyle:"short",timeStyle:"short"},getDateTimeFormatter(_globalize.default.getCurrentDateTimeLocale(),options).format(date);throw new Error("date cannot be null")},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){var days=Math.trunc(ticks/864e9),hours=Math.trunc(ticks%864e9/36e9),minutes=Math.trunc(ticks%36e9/6e8),duration={},hasValue=!1;return days&&(duration.days=days,hasValue=!0),hours&&(duration.hours=hours,hasValue=!0),minutes&&(duration.minutes=minutes,hasValue=!0),hasValue?getDurationFormatter(_globalize.default.getCurrentLocale(),{style:"narrow"}).format(duration):getDisplayRunningTime(ticks)}}});