How to use the react-native-localize.uses24HourClock function in react-native-localize

To help you get started, we’ve selected a few react-native-localize examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gaoxiaosong / react-native-im / standard / util / DateUtil.ts View on Github external
showTime: boolean
) {
    if (isNaN(timestamp)) {
        return '';
    }
    const now = new Date();
    const that = new Date(timestamp);
    const locale = i18n.locale;
    const options: Intl.DateTimeFormatOptions = {
    };
    const isSameDay = sameDay(now, that);
    const isSameWeek = sameWeek(now, that);
    const timeStr = (isSameDay || showTime) ? that.toLocaleTimeString(locale, {
        hour: 'numeric',
        minute: 'numeric',
        hour12: RNLocalize.uses24HourClock(),
    }) : '';
    const dayStr = isSameDay ? '' : isSameWeek ? that.toLocaleDateString(locale, {
        weekday: 'long',
    }) : that.toLocaleDateString(locale, {
        year: 'numeric',
        month: showTime ? 'short' : 'numeric',
        day: 'numeric',
    });
    return [dayStr, timeStr].filter(i => i.length > 0).join(' ');
}