From e70c610c305b7ccef41072005d3c0b3c3ea4c0f2 Mon Sep 17 00:00:00 2001 From: AleDore Date: Fri, 9 Feb 2024 10:18:30 +0100 Subject: [PATCH] fix date --- src/types/mapping/date.ts | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/types/mapping/date.ts b/src/types/mapping/date.ts index 2025a4f..40fd391 100644 --- a/src/types/mapping/date.ts +++ b/src/types/mapping/date.ts @@ -1,8 +1,15 @@ import * as t from "io-ts"; -import { OutputFormat } from "../formatter/date"; + +export const OutputFormat = t.union([ + t.literal("yyyy-MM-dd"), + t.literal("yyyy-MM-dd HH:mm"), + t.literal("yyyy-MM-dd HH:mm:ss"), +]); + +export type OutputFormat = t.TypeOf; const DateStringToUtcFormatMapping = t.type({ - mapper: t.literal("DATE_TO_UTC") + mapper: t.literal("DATE_TO_UTC"), }); type DateStringToUtcFormatMapping = t.TypeOf< @@ -10,27 +17,27 @@ type DateStringToUtcFormatMapping = t.TypeOf< >; const IsoToUtcFormatMapping = t.type({ - mapper: t.literal("ISO_TO_UTC") + mapper: t.literal("ISO_TO_UTC"), }); type IsoToUtcFormatMapping = t.TypeOf; const DateStringToIsoFormatMapping = t.type({ - mapper: t.literal("DATE_TO_ISO") + mapper: t.literal("DATE_TO_ISO"), }); type DateStringToIsoFormatMapping = t.TypeOf< typeof DateStringToIsoFormatMapping >; const DateStringToTimestampFormatMapping = t.type({ - mapper: t.literal("DATE_TO_TIMESTAMP") + mapper: t.literal("DATE_TO_TIMESTAMP"), }); type DateStringToTimestampFormatMapping = t.TypeOf< typeof DateStringToTimestampFormatMapping >; const DateStringFromTimestampFormatMapping = t.type({ - mapper: t.literal("DATE_FROM_TIMESTAMP") + mapper: t.literal("DATE_FROM_TIMESTAMP"), }); type DateStringFromTimestampFormatMapping = t.TypeOf< @@ -42,13 +49,13 @@ export const DateMapping = t.union([ IsoToUtcFormatMapping, DateStringToIsoFormatMapping, DateStringToTimestampFormatMapping, - DateStringFromTimestampFormatMapping + DateStringFromTimestampFormatMapping, ]); export type DateMapping = t.TypeOf; export const ConvertFormatMapping = t.type({ - output: OutputFormat + output: OutputFormat, }); export type ConvertFormatMapping = t.TypeOf;