webix.ajax().stringify() erases timezone info

edited January 5 in Technical questions

Hello,

I have an app that need to get time info, in the browsers zone. For example, if a user is in the +01:00 (Paris) timezone and he inputs 22:00:00, The timezone info should be there so I can tell this is a 21:00:00 UTC timestamp.

I have made some tests and JSON.stringy() default function includes the timezone info. Example:

var value = {time: $$('$datepicker4').getValue()}
JSON.stringify(value);
//=> "{"date":"2017-01-05T21:00:00.000Z"}" 

But when submitting a form, webix uses it's built-in stringify function, resulting in a string without timezone info:

var value = {time: $$('$datepicker4').getValue()}
webix.ajax().stringify(value);
//=> "{"date":"2017-01-05T22:00:00"}"

Is that the expected behavior? If it is, how I can make my form submit this value with the timezone info included?

Comments

  • edited January 11

    Hello,

    To avoid ambiguity dates are parsed and stringified under the same format, which is stored in the locale as webix.i18n.parseFormat. By default it is "%Y-%m-%d "%H:%i". At the same time, Webix Date parser does not process timezones at all.

    Still, you can modify the stringify method in the webix.ajax module to achieve the needed behaviour: http://webix.com/snippet/52ac168f

    This method is used in the library only when issuing server requests, so such a global change will not affect other cases.

  • edited January 17

    That's what I had in min (overriding stringify function), but I end up manually parsing the date before sending to the server.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID Sign In with Twitter

In this Discussion