Skip to content

Instantly share code, notes, and snippets.

@hrsano645
Created September 7, 2008 03:00
Show Gist options
  • Save hrsano645/9223 to your computer and use it in GitHub Desktop.
Save hrsano645/9223 to your computer and use it in GitHub Desktop.
undefined
CmdUtils.CreateCommand({
name: "now-date-format",
homepage: "http://d.hatena.ne.jp/piropati/20080906/1220690703",
author: { name: "hiroshi sano", email: "pirohatiko@gmal.com"},
license: "MPL",
description: "Present time is inserted!",
help: "Present time is inserted!",
_zerofunc: function(dt) {
if(dt < 10) {
return "0" + dt
} else {
return dt
}
},
_fdate: function(){
var date = new Date();
return date.getFullYear() + "/" +
this._zerofunc((date.getMonth()+1)) + "/" +
this._zerofunc(date.getDate()) + " " +
this._zerofunc(date.getHours()) + ":" +
this._zerofunc(date.getMinutes()) + ":" +
this._zerofunc(date.getSeconds()) ;
},
preview: function( pblock ) {
var msg = 'Inserts todays date format: "<i>${predate}</i>"';
pblock.innerHTML = CmdUtils.renderTemplate( msg, {predate: this._fdate()} );
},
execute:function() {
CmdUtils.setSelection(this._fdate());
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment