Sha256: 0e29b8f05274fa6ca38267a74614a87053c2a8e1310926aa5c0611c952a4b87f
Contents?: true
Size: 583 Bytes
Versions: 19
Compression:
Stored size: 583 Bytes
Contents
const mongoose = require('mongoose/browser'); const cql = require('cql-execution'); function DateTime(key, options) { mongoose.SchemaType.call(this, key, options, 'DateTime'); } DateTime.prototype = Object.create(mongoose.SchemaType.prototype); DateTime.prototype.cast = (dateTime) => { if (dateTime.isDateTime) { return dateTime; } if (!Date.parse(dateTime)) { throw new Error(`DateTime: ${dateTime} is not a valid DateTime`); } return cql.DateTime.fromJSDate(new Date(dateTime), 0); }; mongoose.Schema.Types.DateTime = DateTime; module.exports = DateTime;
Version data entries
19 entries across 19 versions & 1 rubygems