1
0
mirror of https://gitlab.nic.cz/turris/reforis/foris-js.git synced 2025-06-16 13:46:16 +02:00

Added date and time utilities.

This commit is contained in:
Maciej Lenartowicz
2020-02-20 14:30:28 +01:00
parent 5939e9dd0e
commit 9fbc4e8383
6 changed files with 63 additions and 3 deletions

8
src/utils/datetime.js Normal file
View File

@ -0,0 +1,8 @@
import moment from "moment";
export function toLocaleDateString(date, { inputFormat, outputFormat = "LLL" } = {}) {
const parsedDate = inputFormat ? moment(date, inputFormat) : moment(date);
return parsedDate
.locale(ForisTranslations.locale)
.format(outputFormat);
}