How to use json-stringify-date - 3 common examples

To help you get started, we’ve selected a few json-stringify-date examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zeit / pkg / test / test-79-npm / json-stringify-date / json-stringify-date.js View on Github external
'use strict';

var stringify = require('json-stringify-date');
var obj = { d: new Date(2014, 2, 4) };
var s = stringify.stringify(obj);
if (s.indexOf('2014') >= 0) {
  console.log('ok');
}
github Mailtrain-org / mailtrain / lib / db.js View on Github external
module.exports.addToCache = (key, value, callback) => {
        if (!value) {
            return setImmediate(() => callback());
        }
        module.exports.redis.multi().
            lpush('mailtrain:cache:' + key, stringifyDate.stringify(value)).
            expire('mailtrain:cache:' + key, 24 * 3600).
            exec(err => callback(err));
    };
github Mailtrain-org / mailtrain / lib / db.js View on Github external
module.exports.redis.rpop('mailtrain:cache:' + key, (err, value) => {
            if (err) {
                return callback(err);
            }
            try {
                value = stringifyDate.parse(value);
            } catch (E) {
                return callback(E);
            }

            return callback(null, value);
        });
    };

json-stringify-date

Like JSON.stringify, but preserve timezones in date objects and parse dates into Date object

MIT
Latest version published 2 years ago

Package Health Score

48 / 100
Full package analysis

Popular json-stringify-date functions