(locale: string, format: string)
| 201 | } |
| 202 | |
| 203 | function getNamedFormat(locale: string, format: string): string { |
| 204 | const localeId = getLocaleId(locale); |
| 205 | NAMED_FORMATS[localeId] ??= Object.create(null); |
| 206 | |
| 207 | if (NAMED_FORMATS[localeId][format]) { |
| 208 | return NAMED_FORMATS[localeId][format]; |
| 209 | } |
| 210 | |
| 211 | let formatValue = ''; |
| 212 | switch (format) { |
| 213 | case 'shortDate': |
| 214 | formatValue = getLocaleDateFormat(locale, FormatWidth.Short); |
| 215 | break; |
| 216 | case 'mediumDate': |
| 217 | formatValue = getLocaleDateFormat(locale, FormatWidth.Medium); |
| 218 | break; |
| 219 | case 'longDate': |
| 220 | formatValue = getLocaleDateFormat(locale, FormatWidth.Long); |
| 221 | break; |
| 222 | case 'fullDate': |
| 223 | formatValue = getLocaleDateFormat(locale, FormatWidth.Full); |
| 224 | break; |
| 225 | case 'shortTime': |
| 226 | formatValue = getLocaleTimeFormat(locale, FormatWidth.Short); |
| 227 | break; |
| 228 | case 'mediumTime': |
| 229 | formatValue = getLocaleTimeFormat(locale, FormatWidth.Medium); |
| 230 | break; |
| 231 | case 'longTime': |
| 232 | formatValue = getLocaleTimeFormat(locale, FormatWidth.Long); |
| 233 | break; |
| 234 | case 'fullTime': |
| 235 | formatValue = getLocaleTimeFormat(locale, FormatWidth.Full); |
| 236 | break; |
| 237 | case 'short': |
| 238 | const shortTime = getNamedFormat(locale, 'shortTime'); |
| 239 | const shortDate = getNamedFormat(locale, 'shortDate'); |
| 240 | formatValue = formatDateTime(getLocaleDateTimeFormat(locale, FormatWidth.Short), [ |
| 241 | shortTime, |
| 242 | shortDate, |
| 243 | ]); |
| 244 | break; |
| 245 | case 'medium': |
| 246 | const mediumTime = getNamedFormat(locale, 'mediumTime'); |
| 247 | const mediumDate = getNamedFormat(locale, 'mediumDate'); |
| 248 | formatValue = formatDateTime(getLocaleDateTimeFormat(locale, FormatWidth.Medium), [ |
| 249 | mediumTime, |
| 250 | mediumDate, |
| 251 | ]); |
| 252 | break; |
| 253 | case 'long': |
| 254 | const longTime = getNamedFormat(locale, 'longTime'); |
| 255 | const longDate = getNamedFormat(locale, 'longDate'); |
| 256 | formatValue = formatDateTime(getLocaleDateTimeFormat(locale, FormatWidth.Long), [ |
| 257 | longTime, |
| 258 | longDate, |
| 259 | ]); |
| 260 | break; |
no test coverage detected