Skip to content

Instantly share code, notes, and snippets.

@mcelotti
Created November 5, 2015 13:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcelotti/a3f8a6a752b0a5e41ae1 to your computer and use it in GitHub Desktop.
Save mcelotti/a3f8a6a752b0a5e41ae1 to your computer and use it in GitHub Desktop.
Ext.define('Ext.ux.TimestampIdentifier', {
alias : 'data.identifier.timestamp',
config : {
negative : false,
string : true
},
constructor : function(config) {
this.initConfig(config);
},
generate : function() {
var ts = new Date().getTime();
if (this._negative) {
ts = -Math.abs(ts);
}
if (this._string) {
return String(ts);
} else {
return ts;
}
}
});
@mcelotti
Copy link
Author

mcelotti commented Nov 5, 2015

Ext.ux.TimestampIdentifier

Usage:

Ext.define('MyModel', {
    extend : 'Ext.data.Model',

    config : {
        identifier : {
            type : 'timestamp',
            negative : true
        },
        fields : ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment