Skip to content

Commit 1e48b16

Browse files
committed
Add humanizeTime to the module i18n API
So modules can access it simply with the right context etc
1 parent 10be90e commit 1e48b16

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

packages/element-web-module-api/element-web-module-api.api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ export interface ExtrasApi {
172172

173173
// @public
174174
export interface I18nApi {
175+
humanizeTime(timeMillis: number): string;
175176
get language(): string;
176177
register(translations: Partial<Translations>): void;
177178
translate(key: keyof Translations, variables?: Variables): string;

packages/element-web-module-api/src/api/i18n.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,10 @@ export interface I18nApi {
4949
* @param variables - Optional variables to interpolate into the translation
5050
*/
5151
translate(key: keyof Translations, variables?: Variables): string;
52+
53+
/**
54+
* Convert a timestamp into a human-readable time string
55+
* @param timeMillis - The time in milliseconds since epoch
56+
*/
57+
humanizeTime(timeMillis: number): string;
5258
}

0 commit comments

Comments
 (0)