Skip to content
Merged
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
18 changes: 14 additions & 4 deletions fluent-bundle/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,22 @@ import { Scope } from "./scope.js";
// Replace with Temporal.* types once they are provided by TypeScript
// In addition to this minimal interface, these objects are also expected
// to be supported by Intl.DateTimeFormat
interface TemporalObject {
epochMilliseconds?: number;
interface TemporalInstant {
epochMilliseconds: number
toString(): string;
}
interface TemporalDateTypes {
calendarId: string;
toZonedDateTime?(timeZone: string): { epochMilliseconds: number };
calendarId?: string;
toString(): string;
}
interface TemporalPlainTime {
hour: number
minute: number
second: number
toString(): string;
}
type TemporalObject = TemporalInstant | TemporalDateTypes | TemporalPlainTime

export type FluentValue = FluentType<unknown> | string;

Expand Down Expand Up @@ -207,7 +217,7 @@ export class FluentDateTime extends FluentType<number | Date | TemporalObject> {
if (value instanceof Date) return value.getTime();

if ("epochMilliseconds" in value) {
return value.epochMilliseconds as number;
return value.epochMilliseconds;
}

if ("toZonedDateTime" in value) {
Expand Down