1.2.8 • Published 5 years ago
@vicis/transform-date v1.2.8

« Vicis Transform Date »
Vicis transformation plugin for date and time.
•• Vicis Documentation •• JavaScript Repository •• Deno Repository ••
💬 Usage
Require CommonJS.
const { Vicis } = require("vicis");
const { VicisTransformDate } = require("@vicis/transform-date");Import as ECMAScript module.
import { Vicis } from "vicis";
import { VicisTransformDate } from "@vicis/transform-date";Export separately as functions.
import {
VicisTransformDate,
toDateTime, toFormat, toHourMinSec, toISO,
toISO8601, toRFC2822, toUnix, toYearMonthDay,
} from "@vicis/transform-date";API
const serializer = Vicis.factory();
const model = { createdAt: new Date(), };
serializer.data(model);Default serializer behaviour
console.log(serializer.getData());{ "createdAt": "2020-06-15T12:30:45.290Z" }toDateTime()
serializer.transform({
createdAt: VicisTransformDate.toDateTime(),
});{ "createdAt": "2020-06-15T12:30:45.000+00:00" }toFormat()
const format = "YYYY-MM-DD HH:mm:ss";
serializer.transform({
createdAt: VicisTransformDate.toFormat(format),
});{ "createdAt": "2020-06-15 12:30:45" }toHourMinSec()
serializer.transform({
createdAt: VicisTransformDate.toHourMinSec(),
});{ "createdAt": "12:30:45" }toISO()
serializer.transform({
createdAt: VicisTransformDate.toISO(),
});{ "createdAt": "2020-06-15T12:30:45.000Z" }toISO8601()
serializer.transform({
createdAt: VicisTransformDate.toISO8601(),
});{ "createdAt": "2020-06-15T12:30:45.000+00:00" }toRFC2822()
serializer.transform({
createdAt: VicisTransformDate.toRFC2822(),
});{ "createdAt": "Mon, 15 Jun 2020 12:30:45 GMT" }toUnix()
serializer.transform({
createdAt: VicisTransformDate.toUnix(),
});{ "createdAt": 1592224245000 }toYearMonthDay()
serializer.transform({
createdAt: VicisTransformDate.toYearMonthDay(),
});{ "createdAt": "2020-06-15" }toDateTime() with configuration
Priority: unixTimestamp, format, anything else for iso formatting.
const config = {
format: undefined,
keepLocalTime: true,
keepOffset: true,
unixTimestamp: false,
utcOffset: undefined,
};
serializer.transform({
createdAt: VicisTransformDate.toDateTime(config),
});{ "createdAt": "2020-06-15T12:30:45.000+00:00" }⚠ For test purposes only ⚠
If you are 💯 sure that you have correct dates and UTC offsets.
serializer.transform({
createdAt: VicisTransformDate,
});{ "createdAt": "2020-06-15T12:30:45.000+00:00" }🗺️ My other projects
1.2.8
5 years ago
1.2.7
5 years ago
1.2.6
5 years ago
1.2.5
5 years ago
1.2.4
5 years ago
1.2.3
5 years ago
1.2.2
6 years ago
1.2.1
6 years ago
1.2.0
6 years ago
1.1.8
6 years ago
1.1.7
6 years ago
1.1.6
6 years ago
1.1.5
6 years ago
1.1.1
6 years ago
1.1.4
6 years ago
1.1.3
6 years ago
1.1.2
6 years ago
1.1.0
6 years ago
1.0.4
6 years ago
1.0.3
6 years ago
1.0.2
6 years ago
1.0.1
6 years ago
1.0.0
6 years ago
0.0.1
6 years ago