Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | 93x 444x 444x 444x 444x 444x 348x 96x | import { IDictionary } from '@zeedhi/core';
/**
* Selects the time format by the rule:
* non-common format > common format
* and if the format is a common format, it will be overriden by timeFormat
*/
export class TimeFormatSelector {
getFormat(format: string, timeFormat: string, useSeconds: boolean) {
const commonsDisplay = ['hh:mm A', 'hh:mm:ss A', 'HH:mm:ss', 'HH:mm'];
const seconds = useSeconds ? ':ss' : '';
const defaultFormats: IDictionary = {
ampm: `hh:mm${seconds} A`,
'24hr': `HH:mm${seconds}`,
};
const timeFormats = ['ampm', '24hr'];
if (commonsDisplay.includes(format) && timeFormats.includes(timeFormat)) {
return defaultFormats[timeFormat];
}
return format;
}
}
|