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:22:55 +00:00
parent a4d18fdce2
commit 9e60cadb70
2 changed files with 8 additions and 9 deletions

View File

@ -62,17 +62,17 @@ class etemplate_widget_date extends etemplate_widget_transformer
$form_name = self::form_name($cname, $this->id);
$value =& self::get_array(self::$request->content, $form_name, false, true);
if($this->type != 'date-duration' && $value)
{
// 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');
}
}
}
@ -109,7 +108,7 @@ class etemplate_widget_date extends etemplate_widget_transformer
{
$value = self::get_array($content, $form_name);
$valid =& self::get_array($validated, $form_name, true);
if ((string)$value === '' && $this->attrs['needed'])
{
self::set_validation_error($form_name,lang('Field must not be empty !!!'));

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"]);