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W,EAAE,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE;gBACxC,EAAE,WAAW,EAAE,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE;gBACxC,EAAE,WAAW,EAAE,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE;gBACxC,EAAE,WAAW,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,EAAE;gBACvC,EAAE,WAAW,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,EAAE;gBAC1C,EAAE,WAAW,EAAE,GAAG,EAAE,YAAY,EAAE,KAAK,EAAE;gBACzC,EAAE,WAAW,EAAE,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE;gBACxC,EAAE,WAAW,EAAE,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE;gBACxC,EAAE,WAAW,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,EAAE;gBAC1C,EAAE,WAAW,EAAE,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE;aACN,CAAC;QAC3C,CAAC;IACL,CAAC,EApEa,wBAAwB,GAAxB,gCAAwB,KAAxB,gCAAwB,QAoErC","file":"dateTimeFormatterService.js","sourcesContent":["import * as _ from \"underscore\";\nimport * as localisationHelper from \"localisationHelper\";\n\n// Models\nimport { ZebraToMomentFormatOptions } from \"Content/ts/Models/Shared/DateTime/dateTimeFormatter\";\n\nexport const Deps = {\n LocalisationHelper: localisationHelper\n};\n\n// Purpose : Zebra uses PHP style dates and times whilst Moment prefers an ISO8601 format. Due to this the primary purpose of \n// this service is to bridge the gap between these technologies without having to create yet more database configuration.\n// Sources : https://momentjs.com/docs/\n// https://www.php.net/manual/en/function.date.php\n// Solution : https://stackoverflow.com/questions/30186611/php-dateformat-to-moment-js-format\nexport module DateTimeFormatterService {\n export const UrlBasedDateFormat = \"YYYY-MM-DD\" as string; // Purpose : Expected format for URL based dates to function with server based calls\n export const InternalMomentTimeFormat = \"HH:mm\" as string;\n export const InternalMomentDateFormat = \"DD MMM YYYY\" as string;\n export const TimeZoneAgnosticAjaxFormat = \"YYYY-MM-DDTHH:mm\" as string;\n export const LocalisedMomentLongDateFormat = Deps.LocalisationHelper.getLocaleSettings().JsLongDateFormat as string;\n export const LocalisedMomentShortDateFormat = Deps.LocalisationHelper.getLocaleSettings().JsShortDateFormat as string;\n export const LocalisedZebraTimeFormat = Deps.LocalisationHelper.getLocaleSettings().ShowMeridian ? \"h:i A\" : \"H:i\" as string;\n export const LocalisedMomentTimeFormat = Deps.LocalisationHelper.getLocaleSettings().ShowMeridian ? \"hh:mm A\" : \"HH:mm\" as string;\n\n export function RetrieveZebraDateFormat(): string {\n return _.reduce(ZebraToMomentFormats(), (previous: string, option: ZebraToMomentFormatOptions) => {\n return previous.replace(option.MomentFormat, option.ZebraFormat);\n }, LocalisedMomentShortDateFormat);\n };\n\n export function RetrieveZebraTimeFormat(): string {\n return _.reduce(ZebraToMomentFormats(), (previous: string, option: ZebraToMomentFormatOptions) => {\n return previous.replace(option.MomentFormat, option.ZebraFormat);\n }, LocalisedMomentTimeFormat);\n };\n\n // Source : https://stackoverflow.com/questions/13627308/add-st-nd-rd-and-th-ordinal-suffix-to-a-number\n export function AppendOrdinalSuffix(day: number): string {\r\n const j = day % 10,\r\n k = day % 100;\r\n\r\n if (j == 1 && k != 11) {\r\n return `${day}st`;\r\n }\r\n\r\n if (j == 2 && k != 12) {\r\n return `${day}nd`;\r\n }\r\n\r\n if (j == 3 && k != 13) {\r\n return `${day}rd`;\r\n }\r\n\r\n return `${day}th`;\n };\n\n function ZebraToMomentFormats(): Array {\n return [\r\n // Special Character Formats\r\n { ZebraFormat: \"/\", MomentFormat: \"/\" },\r\n { ZebraFormat: \"-\", MomentFormat: \"-\" },\r\n { ZebraFormat: \":\", MomentFormat: \":\" },\r\n { ZebraFormat: \" \", MomentFormat: \" \" },\r\n\r\n // Standard Mapped Formats\r\n { ZebraFormat: \"A\", MomentFormat: \"A\" }, // Uppercase Ante meridiem and Post meridiem\r\n { ZebraFormat: \"a\", MomentFormat: \"a\" }, // Lowercase Ante meridiem and Post meridiem\r\n { ZebraFormat: \"D\", MomentFormat: \"ddd\" },\r\n { ZebraFormat: \"d\", MomentFormat: \"DD\" },\r\n { ZebraFormat: \"F\", MomentFormat: \"MMMM\" },\r\n { ZebraFormat: \"H\", MomentFormat: \"HH\" },\r\n { ZebraFormat: \"h\", MomentFormat: \"hh\" },\r\n { ZebraFormat: \"i\", MomentFormat: \"mm\" },\r\n { ZebraFormat: \"j\", MomentFormat: \"D\" },\r\n { ZebraFormat: \"l\", MomentFormat: \"dddd\" },\r\n { ZebraFormat: \"M\", MomentFormat: \"MMM\" },\r\n { ZebraFormat: \"m\", MomentFormat: \"MM\" }, \r\n { ZebraFormat: \"s\", MomentFormat: \"ss\" },\r\n { ZebraFormat: \"Y\", MomentFormat: \"YYYY\" },\r\n { ZebraFormat: \"y\", MomentFormat: \"YY\" }\r\n ] as Array;\r\n }\n}\n"]}