date widget has now api to set or get year, month, date, hours, minutes or time(stamp) and using that in calendar app.js for date manipulation

This commit is contained in:
Ralf Becker 2014-09-05 10:35:08 +00:00
parent 6b4a25e46d
commit bae6b3686f
2 changed files with 111 additions and 2 deletions

View File

@ -1310,8 +1310,10 @@ app.classes.calendar = AppJS.extend(
else
{
jQuery('#calendar-edit_alarm > tbody :nth-child(1)').show();
start.date.setHours(0);
time.set_value(start.get_value() - 60 * def_alarm);
start.set_hours(0);
start.set_minutes(0);
time.set_value(start.get_value());
time.set_value('-'+(60 * def_alarm));
event.set_value(_secs_to_label(60 * def_alarm));
}
}

View File

@ -106,6 +106,113 @@ var et2_date = et2_inputWidget.extend(
}
},
/**
* Set (full) year of current date
*
* @param {number} _value 4-digit year
*/
set_year: function(_value)
{
this.date.setUTCFullYear(_value);
this.set_value(this.date);
},
/**
* Set month (1..12) of current date
*
* @param {number} _value 1..12
*/
set_month: function(_value)
{
this.date.setUTCMonth(_value-1);
this.set_value(this.date);
},
/**
* Set day of current date
*
* @param {number} _value 1..31
*/
set_date: function(_value)
{
this.date.setUTCDate(_value);
this.set_value(this.date);
},
/**
* Set hour (0..23) of current date
*
* @param {number} _value 0..23
*/
set_hours: function(_value)
{
this.date.setUTCHours(_value);
this.set_value(this.date);
},
/**
* Set minute (0..59) of current date
*
* @param {number} _value 0..59
*/
set_minutes: function(_value)
{
this.date.setUTCMinutes(_value);
this.set_value(this.date);
},
/**
* Get (full) year of current date
*
* @return {number|null} 4-digit year or null for empty
*/
get_year: function()
{
return this.input_date.val() == "" ? null : this.date.getUTCFullYear();
},
/**
* Get month (1..12) of current date
*
* @return {number|null} 1..12 or null for empty
*/
get_month: function()
{
return this.input_date.val() == "" ? null : this.date.getUTCMonth()+1;
},
/**
* Get day of current date
*
* @return {number|null} 1..31 or null for empty
*/
get_date: function()
{
return this.input_date.val() == "" ? null : this.date.getUTCDate();
},
/**
* Get hour (0..23) of current date
*
* @return {number|null} 0..23 or null for empty
*/
get_hours: function()
{
return this.input_date.val() == "" ? null : this.date.getUTCHours();
},
/**
* Get minute (0..59) of current date
*
* @return {number|null} 0..59 or null for empty
*/
get_minutes: function()
{
return this.input_date.val() == "" ? null : this.date.getUTCMinutes();
},
/**
* Get timestamp
*
* You can use set_value to set a timestamp.
*
* @return {number|null} timestamp (seconds since 1970-01-01
*/
get_time: function()
{
return this.input_date.val() == "" ? null : this.date.getTime();
},
/**
* Setting date
*