main
Last change
on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 5 days ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
657 bytes
|
Rev | Line | |
---|
[79a0317] | 1 | /*
|
---|
| 2 | MIT License http://www.opensource.org/licenses/mit-license.php
|
---|
| 3 | */
|
---|
| 4 |
|
---|
| 5 | "use strict";
|
---|
| 6 |
|
---|
| 7 | /** @typedef {import("./ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
---|
| 8 | /** @typedef {import("./ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
---|
| 9 |
|
---|
| 10 | class DateObjectSerializer {
|
---|
| 11 | /**
|
---|
| 12 | * @param {Date} obj date
|
---|
| 13 | * @param {ObjectSerializerContext} context context
|
---|
| 14 | */
|
---|
| 15 | serialize(obj, context) {
|
---|
| 16 | context.write(obj.getTime());
|
---|
| 17 | }
|
---|
| 18 |
|
---|
| 19 | /**
|
---|
| 20 | * @param {ObjectDeserializerContext} context context
|
---|
| 21 | * @returns {Date} date
|
---|
| 22 | */
|
---|
| 23 | deserialize(context) {
|
---|
| 24 | return new Date(context.read());
|
---|
| 25 | }
|
---|
| 26 | }
|
---|
| 27 |
|
---|
| 28 | module.exports = DateObjectSerializer;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.