Sha256: 21d2c462bd4a4fc6867495be859b4a789dc05549f0e05ebd5f6a836076e16982

Contents?: true

Size: 518 Bytes

Versions: 11

Compression:

Stored size: 518 Bytes

Contents

const mongoose = require('mongoose');
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 (!Date.parse(dateTime)) {
    throw new Error(`DateTime: ${dateTime} is not a valid DateTime`);
  }

  return cql.DateTime.fromDate(new Date(dateTime), 0);
};

mongoose.Schema.Types.DateTime = DateTime;
module.exports = DateTime;

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
cqm-models-0.8.4 app/assets/javascripts/basetypes/DateTime.js
cqm-models-0.8.3 app/assets/javascripts/basetypes/DateTime.js
cqm-models-0.8.2 app/assets/javascripts/basetypes/DateTime.js
cqm-models-0.8.1 app/assets/javascripts/basetypes/DateTime.js
cqm-models-0.8.0 app/assets/javascripts/basetypes/DateTime.js
cqm-models-0.7.7 app/assets/javascripts/basetypes/DateTime.js
cqm-models-0.7.6 app/assets/javascripts/basetypes/DateTime.js
cqm-models-0.7.5 app/assets/javascripts/basetypes/DateTime.js
cqm-models-0.7.4 app/assets/javascripts/basetypes/DateTime.js
cqm-models-0.7.3 app/assets/javascripts/basetypes/DateTime.js
cqm-models-0.7.2 app/assets/javascripts/basetypes/DateTime.js