• download
  • documentation
  • forums
  • demo
  • contact
  • blog

meteora

javascript widgets

Documentation

  • Autocomplete
  • Bubble
  • Calendar
  • Carousel
  • Datagrid
  • Dialog
  • Editor
  • Effect
  • Filebrowser
  • Form
  • Jsonrpc
  • Menu
  • Notebook
  • Picbox
  • Popup
  • Searchlist
  • Selection
  • Spinbutton
  • Tablesort
  • Toolbox
  • Treeview
In order to post messages on this forum, you must be registered and logged in
80x80:1760834185_unknown.png
Forums » Suggestions » Wishlist

calendar __exportDate as unix timestamp

Posted by Sylvain Batteux

Hi,

Would it be good to save a date as timestamp instead of humanize format ? YES !

So I made a new function in the calendar.JS file :

'__unixize': function(val,anneev,moisv,jourv) {

var sdate = val;

var tmpdate = new Date();

var annee = parseInt(anneev)*1;

var mois = parseInt(moisv)-1;

var jour = parseInt(jourv)*1;

tmpdate.setFullYear(annee);

tmpdate.setMonth(mois);

tmpdate.setDate(jour);

tmpdate.setHours(0);

tmpdate.setMinutes(0);

tmpdate.setSeconds(0);

tmpdate.setMilliseconds(0);

tsdate = tmpdate.getTime()/1000;

return tsdate;

},

I have inserted it right after the '__zeroize' function.

As well, we have to add a new pattern in the pattern list :

'patterns': {

'X': '(\\d{12})',

'Y': '(\\d{4})',

'm': '(\\d{2})',

'd': '(\\d{2})',

'H': '(\\d{2})',

'i': '(\\d{2})',

's': '(\\d{2})',

'j': '(\\d+)',

'g': '(\\d+)',

'h': '(\\d+)',

'n': '(\\d+)',

'k': '(\\d+)',

'z': '(\\d+)',

'a': '([apm]+)',

'G': '(\\d+)',

'A': '([APM]+)'

},

And of course, we have to add the new format in the __exportDate function :

(I have added it in the $extend part)

$extend(

this.__map,

{

// Day of the month with leading zeros

'd': this.__zeroize(this.__map['j']),

// Numeric month with leading zeros

'm': this.__zeroize(this.__map['n']),

// 24-hour format of an hour with leading zeros

'H': this.__zeroize(this.__map['G']),

// 12-hour format of an hour with leading zeros

'h': this.__zeroize(this.__map['g']),

// Minutes with leading zeros

'i': this.__zeroize(this.__map['k']),

// Seconds with leading zeros

's': this.__zeroize(this.__map['z']),

// Uppercase AM or PM

'A': this.__map['a'].toUpperCase

// Export a timestamp formatted date

'X': this.__unixize(this.value,this.__map['Y'],this.__map['n'],this.__map['j'])

}

);</P>

  • Monday March 30, 2009 @ 08:39 date
  • Sylvain Batteux user
50x50:1760834185_unknown.png
link Wednesday April 1, 2009 @ 17:01

comment J. Carlos Nieto

Hi,

I've just merged your patch with a few extra changes I've made. I updated 0.7 with some other bugfixes (it's 0.7.1 now), could you test it please?

Thanks for your code!

50x50:1760834185_unknown.png
link Thursday May 7, 2009 @ 09:58

comment Sylvain Batteux

Hi Xiam,

sorry for testing this so late, but I'm on big projects….

So I noticed that in 0.7.1 in calendar.js, on line 75 that you omitted to minus the month of 1. In Javascript, January is number 0 and not 1. So in the date function, the figures that are output needs to be minus of 1.

ex : If you select 7th of june 2009 in the example page, it will show timestamp 1246917600 which in fact is 7th of july 2009 (attention, I am on time zone GMT+1).

So here is the correction (but you might want to adapt) : cursor.setMonth(parseInt(map['n'])-1);

cheers :)

Copyright © 2007-2009 Astrata Software.