Commit 7b44bc54 authored by nanahira's avatar nanahira

update date transform

parent 5aadfe8d
......@@ -138,6 +138,17 @@ export const DateColumn = (
return MergePropertyDecorators([
Column('timestamp', columnDecoratorOptions(options)),
IsDate(),
Transform(
(v) => {
if (v.value == null) return v.value;
if (v.value instanceof Date) return v.value;
if (typeof v.value === 'number') return new Date(v.value * 1000);
return new Date(v.value);
},
{
toClassOnly: true,
},
),
validatorDecorator(options),
swaggerDecorator(options, { type: Date }),
]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment