Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui): use correct type definitions for createNativeLocaleFormatter… #440

Merged
merged 1 commit into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 24 additions & 6 deletions ui/src/utils/Timestamp.json
Original file line number Diff line number Diff line change
Expand Up @@ -1165,7 +1165,7 @@
"type": "Function",
"tsType": "TimestampFormatOptions",
"required": true,
"desc": "A function that passes the timestamp and a boolean",
"desc": "A function that passes the timestamp and a boolean, and returns an Intl.DateTimeFormatter",
"__exemption": [ "examples" ],
"params": {
"timestamp": {
Expand All @@ -1182,7 +1182,7 @@
},
"returns": {
"type": "Object",
"tsType": "TimestampFormatter",
"tsType": "Intl.DateTimeFormatOptions",
"desc": "This uses the Intl.DateTimeFormat function of the browser. Options are specified [here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat)",
"examples": [
"{ timeZone: 'UTC', month: 'long' }",
Expand All @@ -1194,9 +1194,27 @@
}
},
"returns": {
"type": "String",
"desc": "The output of the operation",
"type": "Function",
"desc": "A function that takes a timestamp and a boolean and returns a formatted string.",
"tsType": "TimestampFormatter",
"params": {
"timestamp": {
"type": "Object",
"tsType": "Timestamp",
"desc": "A timestamp object",
"__exemption": [ "examples" ]
},
"short": {
"type": "Boolean",
"desc": "if true, specifies to use the short version (ie: 'Monday' to be returns as 'Mon', 'January' to be returned as 'Jan', etc)",
"__exemption": [ "examples" ]
}
},
"returns": {
"type": "String",
"desc": "A string containing the formatted date/time",
"__exemption": [ "examples" ]
}
},
"__exemption": [ "examples" ]
},
Expand Down Expand Up @@ -1511,7 +1529,7 @@
"weekdayFormatter('Sun', 'long', 'de')",
"weekdayFormatter('Fri', 'short', 'fr')",
"weekdayFormatter('Sat', 'narrow', 'fi')"
]
]
}
},
"getWeekdayNames": {
Expand Down Expand Up @@ -1583,7 +1601,7 @@
"monthFormatter('Sun', 'long', 'de')",
"monthFormatter('Fri', 'short', 'fr')",
"monthFormatter('Sat', 'narrow', 'fi')"
]
]
}
},
"getMonthNames": {
Expand Down
2 changes: 1 addition & 1 deletion ui/types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export type TimestampArray = Timestamp[]
export type TimestampOrNull = Timestamp | null

export type TimestampFormatter = (timestamp: Timestamp, short: boolean) => string;
export type TimestampFormatOptions = (timestamp: Timestamp, short: boolean) => TimestampFormatter;
export type TimestampFormatOptions = (timestamp: Timestamp, short: boolean) => Intl.DateTimeFormatOptions;
export type TimestampMoveOperation = (timestamp: Timestamp) => Timestamp;

export interface TimeObject {
Expand Down