BBO Discussion Forums: timestamps - BBO Discussion Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

timestamps better way to handle client/server timestamps

#1 User is offline   monist 

  • Pip
  • Group: Members
  • Posts: 7
  • Joined: 2016-April-14

Posted 2024-March-28, 22:12

Just looked at my most recent tourney result. Stated time of the game had not even arrived in my timezone. Here's an easy solution I use on my site:

) Server sends all DateTimeStamps as Unix epoch time
) Browser JS client converts to local time where user is located
) added bonus: epoch time is very compact

Here's an example function for the client side, which is simple and readable, but could easily be made to contain more detail:


const get_DayHourMin = (epoch_secs) => { // example of return val: Thu 1:45p

const date_str = `${new Date(epoch_secs * 1000)}`

const timestamp_ary = date_str.match(/^(\w{3}).+(\d\d):(\d\d):\d\d/)

const day = timestamp_ary[1]

let hour = Number(timestamp_ary[2])

let min = timestamp_ary[3]

if (hour > 12) { // make 24hr time 12hr time

hour -= 12
min += "p" // p.m.
}
else { min += "a" } // a.m.

return `${day} ${hour}:${min}`
}

In general, I think y'all's site is amazing, and I play way to much online bridge. I've borrowed a bunch of ideas from you for my site word game site -- https://lexluv.com -- especially the concept of a new user session causing the previous client to shut down. BTW, you should also investigate push notifications...

Cheers!
0

#2 User is offline   barmar 

  • PipPipPipPipPipPipPipPipPipPipPipPip
  • Group: Admin
  • Posts: 21,415
  • Joined: 2004-August-21
  • Gender:Male

Posted 2024-April-11, 09:34

This is the first I've heard anyone report a problem. The way it currently works is that the browser sends its timezone offset to the server, and the server adjusts all times by this offset.

You're talking about myhands, right?

#3 User is offline   pescetom 

  • PipPipPipPipPipPipPipPip
  • Group: Advanced Members
  • Posts: 7,329
  • Joined: 2014-February-18
  • Gender:Male
  • Location:Italy

Posted 2024-April-11, 16:19

View Postbarmar, on 2024-April-11, 09:34, said:

This is the first I've heard anyone report a problem. The way it currently works is that the browser sends its timezone offset to the server, and the server adjusts all times by this offset.

You're talking about myhands, right?


Even History gets the timestamp wrong, not that it bothers me much.
I just played a tourney starting at 9pm CET and in History it shows as 14:01.
0

#4 User is offline   0 carbon 

  • PipPipPipPipPip
  • Group: Full Members
  • Posts: 512
  • Joined: 2009-January-19
  • Gender:Male

Posted 2024-April-13, 21:22

I get different results with different browsers at https://webutil.brid...lobalClub&md=10

I've had to use Spoof Timezone addin.
0

#5 User is offline   barmar 

  • PipPipPipPipPipPipPipPipPipPipPipPip
  • Group: Admin
  • Posts: 21,415
  • Joined: 2004-August-21
  • Gender:Male

Posted 2024-April-15, 14:07

Tourname times in History are shown in BBO's server time, which is US Central Time. I'm not sure why we don't translate it to local time, but it's been llike this for ages.

Times in myhands are converted to local time.

#6 User is offline   pescetom 

  • PipPipPipPipPipPipPipPip
  • Group: Advanced Members
  • Posts: 7,329
  • Joined: 2014-February-18
  • Gender:Male
  • Location:Italy

Posted 2024-April-15, 14:37

View Postbarmar, on 2024-April-15, 14:07, said:

Tourname times in History are shown in BBO's server time, which is US Central Time. I'm not sure why we don't translate it to local time, but it's been llike this for ages.

Times in myhands are converted to local time.


It would make sense to translate history to local time too.
Not that it's in the top 100 on my own list of to do eventually, or that I have great hopes for the top 20 :)
0

#7 User is offline   0 carbon 

  • PipPipPipPipPip
  • Group: Full Members
  • Posts: 512
  • Joined: 2009-January-19
  • Gender:Male

Posted 2024-April-21, 11:57

View Postpescetom, on 2024-April-15, 14:37, said:

It would make sense to translate history to local time too.
Not that it's in the top 100 on my own list of to do eventually, or that I have great hopes for the top 20 :)


With daylight savings time, I can see some complexities calculating what time to display for every hand/tourney in the past.

Suggestion: BBO should start using UTC - no DST to worry about, no time zones. The military uses if for the same reason - they call it Zulu time, eg, 1901z
0

#8 User is offline   barmar 

  • PipPipPipPipPipPipPipPipPipPipPipPip
  • Group: Admin
  • Posts: 21,415
  • Joined: 2004-August-21
  • Gender:Male

Posted 2024-April-22, 14:21

View Post0 carbon, on 2024-April-21, 11:57, said:

With daylight savings time, I can see some complexities calculating what time to display for every hand/tourney in the past.

Suggestion: BBO should start using UTC - no DST to worry about, no time zones. The military uses if for the same reason - they call it Zulu time, eg, 1901z

Most humans don't understand UTC, this would hardly be an improvement.

#9 User is offline   pescetom 

  • PipPipPipPipPipPipPipPip
  • Group: Advanced Members
  • Posts: 7,329
  • Joined: 2014-February-18
  • Gender:Male
  • Location:Italy

Posted 2024-April-22, 15:29

View Postbarmar, on 2024-April-22, 14:21, said:

Most humans don't understand UTC, this would hardly be an improvement.

I understand (or at least have learned) that you prefer to play bridge rather than improve BBO, but surely the suggestion was entirely sensible: UTC would be translated into their current timezone with no error of DST, assuming BBO had the minimal energy to explain to its own software that the basis was no longer US central time but UTC :)
0

#10 User is offline   smerriman 

  • PipPipPipPipPipPipPip
  • Group: Advanced Members
  • Posts: 3,771
  • Joined: 2014-March-15
  • Gender:Male

Posted 2024-April-22, 16:35

View Postpescetom, on 2024-April-22, 15:29, said:

but surely the suggestion was entirely sensible: UTC would be translated into their current timezone with no error of DST

I can't see anything remotely sensible about the suggestion, so we must be understanding it differently. 0 carbon was suggesting the History tab shows times in UTC with no 'translation in the current timezone' at all. This would mean the time shown would be "wrong" for virtually every user.. local would obviously be better (though I'm well aware that it is not as trivial as it sounds), but the current setup of BBO time is at least understandable.
0

#11 User is offline   mycroft 

  • Secretary Bird
  • PipPipPipPipPipPipPipPip
  • Group: Advanced Members
  • Posts: 7,124
  • Joined: 2003-July-12
  • Gender:Male
  • Location:Calgary, D18; Chapala, D16

Posted 2024-April-22, 16:46

Browsers can calculate time from anywhere.

Displaying UTC is unhelpful for most humans, so I'm assuming you're going to have everything add javascript to "home it" for the user. Which puts us back where we were.

I do realize that UTC is much better understood when in UK time or UTC+1/+2, but for the majority of NA, the numbers are difficult enough to autocorrect even if we do know what our "number" is.

Of course, since I'm now 90+% UTC-6 (Mountain Daylight Time or Central Standard Time) it doesn't much matter (but I did have to look up to confirm that yes, it is UTC-6. I do time conversions all the time for my job, and still aren't 100% sure what time it is here relative to UTC).
When I go to sea, don't fear for me, Fear For The Storm -- Birdie and the Swansong (tSCoSI)
0

#12 User is offline   pescetom 

  • PipPipPipPipPipPipPipPip
  • Group: Advanced Members
  • Posts: 7,329
  • Joined: 2014-February-18
  • Gender:Male
  • Location:Italy

Posted 2024-April-24, 09:11

View Post0 carbon, on 2024-April-21, 11:57, said:

With daylight savings time, I can see some complexities calculating what time to display for every hand/tourney in the past.

Suggestion: BBO should start using UTC - no DST to worry about, no time zones. The military uses if for the same reason - they call it Zulu time, eg, 1901z



View Postsmerriman, on 2024-April-22, 16:35, said:

I can't see anything remotely sensible about the suggestion, so we must be understanding it differently. 0 carbon was suggesting the History tab shows times in UTC with no 'translation in the current timezone' at all. This would mean the time shown would be "wrong" for virtually every user.. local would obviously be better (though I'm well aware that it is not as trivial as it sounds), but the current setup of BBO time is at least understandable.

As I read his quote above in the context of the discussion, he was suggesting that while they fix the issue of only translating times in Hands but not in History, they could also migrate from DST to UTC as a base to avoid the "daylight savings time" issue as well.
In any case, not on my top 100 problems list :)
0

#13 User is offline   pescetom 

  • PipPipPipPipPipPipPipPip
  • Group: Advanced Members
  • Posts: 7,329
  • Joined: 2014-February-18
  • Gender:Male
  • Location:Italy

Posted 2024-April-24, 09:15

View Postmycroft, on 2024-April-22, 16:46, said:

I do realize that UTC is much better understood when in UK time or UTC+1/+2, but for the majority of NA, the numbers are difficult enough to autocorrect even if we do know what our "number" is.

Of course, since I'm now 90+% UTC-6 (Mountain Daylight Time or Central Standard Time) it doesn't much matter (but I did have to look up to confirm that yes, it is UTC-6. I do time conversions all the time for my job, and still aren't 100% sure what time it is here given UTC).


As you say UTC is better understood in Europe however (where BBO's programmers are) and from where the DST/EST issue need some looking up too :)
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users

  1. Facebook