mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2025-11-13 08:13:49 +10:00
fix(client): show "present" string if end date is not entered, also add to i18n locales
fix #653
This commit is contained in:
@ -15,6 +15,9 @@
|
|||||||
"markdown": {
|
"markdown": {
|
||||||
"help-text": "This section supports <1>markdown</1> formatting."
|
"help-text": "This section supports <1>markdown</1> formatting."
|
||||||
},
|
},
|
||||||
|
"date": {
|
||||||
|
"present": "Present"
|
||||||
|
},
|
||||||
"subtitle": "A free and open source resume builder.",
|
"subtitle": "A free and open source resume builder.",
|
||||||
"title": "Reactive Resume",
|
"title": "Reactive Resume",
|
||||||
"toast": {
|
"toast": {
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import { DateRange } from '@reactive-resume/schema';
|
|||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import isEmpty from 'lodash/isEmpty';
|
import isEmpty from 'lodash/isEmpty';
|
||||||
import isString from 'lodash/isString';
|
import isString from 'lodash/isString';
|
||||||
|
import { i18n } from 'next-i18next';
|
||||||
|
|
||||||
export const dateFormatOptions: string[] = [
|
export const dateFormatOptions: string[] = [
|
||||||
'MMMM DD, YYYY',
|
'MMMM DD, YYYY',
|
||||||
@ -21,6 +22,8 @@ export const dateFormatOptions: string[] = [
|
|||||||
export const getRelativeTime = (timestamp: dayjs.ConfigType): string => dayjs(timestamp).toNow(true);
|
export const getRelativeTime = (timestamp: dayjs.ConfigType): string => dayjs(timestamp).toNow(true);
|
||||||
|
|
||||||
export const formatDateString = (date: string | DateRange, formatStr: string): string | null => {
|
export const formatDateString = (date: string | DateRange, formatStr: string): string | null => {
|
||||||
|
const presentString = i18n?.t('common.date.present') ?? '';
|
||||||
|
|
||||||
if (isEmpty(date)) return null;
|
if (isEmpty(date)) return null;
|
||||||
|
|
||||||
// If `date` is a string
|
// If `date` is a string
|
||||||
@ -39,5 +42,5 @@ export const formatDateString = (date: string | DateRange, formatStr: string): s
|
|||||||
return `${dayjs(date.start).format(formatStr)} - ${dayjs(date.end).format(formatStr)}`;
|
return `${dayjs(date.start).format(formatStr)} - ${dayjs(date.end).format(formatStr)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return dayjs(date.start).format(formatStr);
|
return `${dayjs(date.start).format(formatStr)} - ${presentString}`;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user