fixed date client/server protocol to always just append "Z" after seconds, so apps can compare date values

This commit is contained in:
Ralf Becker 2014-09-10 10:25:06 +00:00
parent c775582af2
commit f691946560
2 changed files with 8 additions and 9 deletions

View File

@ -68,11 +68,11 @@ class etemplate_widget_date extends etemplate_widget_transformer
// string with formatting letters like for php's date() method
if ($this->attrs['dataformat'] && !is_numeric($value))
{
$date = date_create_from_format($this->attrs['dataformat'], $value, new DateTimeZone('UTC'));
$date = date_create_from_format($this->attrs['dataformat'], $value, egw_time::$user_timezone);
}
else
{
$date = new egw_time((int)$value, new DateTimeZone('UTC'));
$date = new egw_time($value);
}
if($this->type == 'date-timeonly')
{
@ -80,9 +80,8 @@ class etemplate_widget_date extends etemplate_widget_transformer
}
if($date)
{
// Set timezone to UTC so javascript doesn't add/subtract anything
$date->setTimezone(new DateTimeZone('UTC'));
$value = $date->format(egw_time::W3C);
// postfix date-string with "Z" so javascript doesn't add/subtract anything
$value = $date->format('Y-m-d\TH:i:s\Z');
}
}
}

View File

@ -206,7 +206,7 @@ var et2_date = et2_inputWidget.extend(
*
* You can use set_value to set a timestamp.
*
* @return {number|null} timestamp (seconds since 1970-01-01
* @return {number|null} timestamp (seconds since 1970-01-01)
*/
get_time: function()
{
@ -390,7 +390,7 @@ var et2_date = et2_inputWidget.extend(
// Convert to timestamp - no seconds
this.date.setSeconds(0,0);
return this.date.toJSON();
return this.date.toJSON().replace(/\.\d{3}Z$/, 'Z');
}
});
et2_register_widget(et2_date, ["date", "date-time", "date-timeonly"]);