|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
791 bytes
|
| Rev | Line | |
|---|
| [9af201e] | 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 | * Serializes this instance into the provided serializer context.
|
|---|
| 13 | * @param {Date} obj date
|
|---|
| 14 | * @param {ObjectSerializerContext} context context
|
|---|
| 15 | */
|
|---|
| 16 | serialize(obj, context) {
|
|---|
| 17 | context.write(obj.getTime());
|
|---|
| 18 | }
|
|---|
| 19 |
|
|---|
| 20 | /**
|
|---|
| 21 | * Restores this instance from the provided deserializer context.
|
|---|
| 22 | * @param {ObjectDeserializerContext} context context
|
|---|
| 23 | * @returns {Date} date
|
|---|
| 24 | */
|
|---|
| 25 | deserialize(context) {
|
|---|
| 26 | return new Date(context.read());
|
|---|
| 27 | }
|
|---|
| 28 | }
|
|---|
| 29 |
|
|---|
| 30 | module.exports = DateObjectSerializer;
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.