Socket
Book a DemoInstallSign in
Socket

ampersand-state-mixin-datatype-iso-date

Package Overview
Dependencies
Maintainers
2
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ampersand-state-mixin-datatype-iso-date

Adds a date datatype to ampersand-state using ISO 8601 locale strings

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
2
Created
Source

Codeship Status for cdaringe/ampersand-state-mixin-datatype-iso-date

ampersand-state-mixin-datatype-iso-date

Adds ISO 8601 date functionality to ampersand state. This module stores dates explicity as full ISO 8601 strings with client locale TZ. This makes all timestamps lossless, vs using UTC ISO stamps or Unix time (epoch) values.

// same time, different formats
"2015-07-04T15:26:19-07:00" // good! lossless timestamp data, keeping client TZ. we use this
"2015-07-04T22:26:19.000Z" // poor! UTC normalized.  drops user TZ
1436048779 // poor! unix time, UTC normalized (maybe!*). drops user TZ

You may want to specify something like the following in your ampersand-states or ampersand-models:

var State = require('ampersand-state');
var DateState = State.extend(isoDateMixin, {
    props: {
        sometime: 'iso-date'
    }
});

usage

Using the example from above

var State = require('ampersand-state');
var funcMixin = require('ampersand-state-mixin-datatype-iso-date');
var DateState = State.extend(funcMixin, {
    props: {
        sometime: {
            type: 'iso-date',
            required: true
        }
    }
});

var model = new DateState({
    myTime: new Date()
});
model.myTime; //=> "2015-07-04T15:26:19-07:00"

model.myTime = "2015-07-04 16:30:20-07:00"; // no T is still ISO compliant. some DBs, like postgres, omit it by default
model.myTime; //=> "2015-07-04T16:30:20-07:00";

model.myTime = '10/10/2010'; // Using incomplete timestamps is deprecated in this module's moment.js dep, thus not recommended
model.myTime; //=> "2010-10-10T00:00:00-07:00" (caution!)

Keywords

ampersand

FAQs

Package last updated on 31 Aug 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts