mirror of
https://github.com/home-assistant/frontend.git
synced 2025-11-09 02:49:51 +00:00
Ts all the tests (#1998)
* Convert tests to TypeScript * Add types for tests * Rename files to TS * Fix up test imports * Fix TSC errors * Liiiint * Add types to util method signatures * Some more types
This commit is contained in:
22
src/common/datetime/format_date_time.ts
Normal file
22
src/common/datetime/format_date_time.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import * as fecha from "fecha";
|
||||
|
||||
// Check for support of native locale string options
|
||||
function toLocaleStringSupportsOptions() {
|
||||
try {
|
||||
new Date().toLocaleString("i");
|
||||
} catch (e) {
|
||||
return e.name === "RangeError";
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export default (toLocaleStringSupportsOptions()
|
||||
? (dateObj: Date, locales: string) =>
|
||||
dateObj.toLocaleString(locales, {
|
||||
year: "numeric",
|
||||
month: "long",
|
||||
day: "numeric",
|
||||
hour: "numeric",
|
||||
minute: "2-digit",
|
||||
})
|
||||
: (dateObj: Date) => fecha.format(dateObj, "haDateTime"));
|
||||
Reference in New Issue
Block a user