Menu

Why convert to UTC?

Anonymous
2009-01-20
2012-12-06
  • Anonymous

    Anonymous - 2009-01-20

    Why does the hand history parser convert to UTC before saving to the database? Shouldn't we just save according to how the history is written in the file?  This is coming up for me because I added some code to get the graphing dates working and I expect those dates to search by when I played a hand, not in UTC but in ET, my timezone.  If I comment out the parser code that converts that date, then I can filter the graph as I would expect:

    line 885 of fpdb_simple.py:

    #    if (site=="ftp" or site=="ps") and not isUTC: #these use US ET
    #        result+=datetime.timedelta(hours=5)

    Is there a reason this is in there or a compromise that can be made for this code?

     
    • Carl G

      Carl G - 2009-01-21

      "Why does the hand history parser convert to UTC before saving to the database?"

      To make the dates consistent between sites and make graphing easier. A large number of players play from Europe and other countries, and many other sites dont use ET or CET as the default - and dont tell you in the HH file that its UTC, localtime or other.

      I haven't added it as yet, but this:
      select CONVERT_TZ(Hands.handStart,'+00:00','+09:00') from Hands;

      Automatically converts from UTC to my timezone when pulling from the database.

      The correct solution is to convert to UTC and grab the hands based on the users local timezone.

       
      • Anonymous

        Anonymous - 2009-01-22

        So if we were taking dates from users (who would expect those dates to be i their timezone) and used it to query the database, we should run this conversion when we actually query the database:

        CONVERT_TZ(%s, 'SYSTEM', 'UTC')

        That makes sense, and it even works too. :)

        Thanks.

         

Log in to post a comment.