Telegram Web K with changes to work inside I2P https://web.telegram.i2p/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
947 B

3 years ago
/*
* https://github.com/morethanwords/tweb
* Copyright (C) 2019-2021 Eduard Kuzmenko
* https://github.com/morethanwords/tweb/blob/master/LICENSE
*/
3 years ago
import I18n, { i18n, join, LangPackKey } from "../lib/langPack";
3 years ago
import formatDuration, { DurationType } from "./formatDuration";
const CALL_DURATION_LANG_KEYS: {[type in DurationType]: LangPackKey} = {
s: 'Seconds',
m: 'Minutes',
h: 'Hours',
d: 'Days',
w: 'Weeks'
};
3 years ago
export default function formatCallDuration(duration: number, plain?: boolean) {
3 years ago
const a = formatDuration(duration, 2);
3 years ago
if(plain) {
const strings = a.map((d) => I18n.format(CALL_DURATION_LANG_KEYS[d.type], true, [d.duration]));
3 years ago
return join(strings, false, plain);
}
const elements = a.map((d) => i18n(CALL_DURATION_LANG_KEYS[d.type], [d.duration]));
3 years ago
const fragment = document.createElement('span');
fragment.append(...join(elements, false));
return fragment;
}