Skip to content

Commit 5f624fd

Browse files
authored
Merge pull request #137 from element-hq/dbkr/human_eyes
Add humanizeTime to the module i18n API
2 parents 28ad600 + da8e67a commit 5f624fd

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-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
@@ -173,6 +173,7 @@ export interface ExtrasApi {
173173

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

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,11 @@ 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 translated, human-readable time,
55+
* using the current system time as a reference, eg. "5 minutes ago".
56+
* @param timeMillis - The time in milliseconds since epoch
57+
*/
58+
humanizeTime(timeMillis: number): string;
5259
}

0 commit comments

Comments
 (0)