Skip to content

Instantly share code, notes, and snippets.

@adonese
Last active March 30, 2018 11:55
Show Gist options
  • Save adonese/6efd911b5bd2d90401aad62fb0e1179f to your computer and use it in GitHub Desktop.
Save adonese/6efd911b5bd2d90401aad62fb0e1179f to your computer and use it in GitHub Desktop.
Morsal timezone issue.

How DateTime is parsed in Morsal

I must stress that working with time is always a major-bug source.

I have checked both GWD {Consumer,Terminal} API documentation, as well as the source code. Here is how our CMS handles the timezone. Again, I have already mentioned that in a previous email, but it is nevertheless important to make sure that we all understand how our CMS handles timezone.

  • You can either send the time, in any tranDateTime parameter, as YYYY-MM-ddThh:mm[:ss]Z, in this case, the time should be sent in UTC. This is what causes the +2:00 issue. In our CMS, we have set our timezone as Khartoum, which is UTC+2:00, so when we receive any request, we instantaneously convert it to the appropiriate timezone, the timezone that is recognized by EBS, which is UTC+2:00. All that depends on the fact that any tranDateTime is received by CMS as UTC time. What we are doing now is sending our time in UTC+2:00! This is bug. It is neither from CMS, nor Alaa Aldin, nor EBS.
  • Or, we can send the tranDateTime as YYYY-MM-ddThh:mm[:ss], and do note the absence of the Z. If you decided to use this format, you will need to do the time conversion yourself! OUR CMS and EBS both will understand that you have already sent the time in UTC+2:00. I, with Mohamed Jaafar, have checked your android source code. He helped me actually made a small application that shows the sent time. Here is your problem
    • You get the current time, a variable called now. This variable will be later sent as tranDateTime. This variable gets the user's current datetime, and send it as is. It should first convert it to UTC, and then send it.
    • Also, your time formatter is something like this YYYY-MM-ddThh:mm:ssZ, again note the Z.
    • To solve that, after we get the user's current time, we convert it to UTC, then send it through your dateTime formatter. This is the proper approach. There won't be any hardcodig nor hacky ways, it is how the system is intended to work.
    • Or (please don't do it), remove the Z from your dateTime formatter and then the date as is.

If you have any other questions please let us now.

https://imgs.xkcd.com/comics/supervillain_plan.png

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment