1

I have rankings by country and month, I need to reset the ranking at the beginning of the month 1st day at 00:00.

I have a cron task every 15 minutes checking if with the timezone of the country is day 1 of the month at 0:00 (because some timezones have deviations +x.45 or +x.30 minutes). But, what is the criteria when the country has different timezones?

By example, when is the start time of BlackFriday in one country like USA with different timezones?.

SeViR
  • 11
  • 2

2 Answers2

1

Welcome to the wonderful, horrible world of time! ;-)

In the USA we don't have a unique start time of "Black Friday". We don't even all celebrate New Years at the same moment. Instead we follow our local time zone rules. Not only are there multiple time zone rules covering the single country, even some individual states observe more than one time zone (e.g. Tennessee).

Here is a global map of time zones.

Howard Hinnant
  • 206,506
  • 52
  • 449
  • 577
  • Ok, and how you can implement a global USA week ranking? the week starts in a different moments so, I don't know it that is possible. – SeViR Nov 16 '18 at 19:00
0

By example, when is the start time of BlackFriday in one country like USA with different timezones?.

Assuming you mean the shopping holiday that follows Thanksgiving Day, which falls this year on Friday, November 23rd 2018:

Time Zone                   |  Local Start Time            |  UTC Equivalent
----------------------------+------------------------------|------------------------
Guam & Northern Mariana Is. |  2018-11-23T00:00:00+10:00   |  2018-11-22T14:00:00Z
Atlantic (PR, VI)           |  2018-11-23T00:00:00-04:00   |  2018-11-23T04:00:00Z 
Eastern                     |  2018-11-23T00:00:00-05:00   |  2018-11-23T05:00:00Z 
Central                     |  2018-11-23T00:00:00-06:00   |  2018-11-23T06:00:00Z 
Mountain                    |  2018-11-23T00:00:00-07:00   |  2018-11-23T07:00:00Z 
Pacific                     |  2018-11-23T00:00:00-08:00   |  2018-11-23T08:00:00Z
Alaska                      |  2018-11-23T00:00:00-09:00   |  2018-11-23T09:00:00Z 
Hawaii                      |  2018-11-23T00:00:00-10:00   |  2018-11-23T10:00:00Z 
American Samoa              |  2018-11-23T00:00:00-11:00   |  2018-11-23T11:00:00Z

I have no idea if Black Friday is actually observed in all US territories or not.

As you can see, a single calendar date cannot be mapped to a single range of absolute time, especially when applied to a country with multiple time zones.

BTW, things are even more complicated if you were talking about a date that fell during daylight saving time. For example, much of Arizona doesn't observe DST while the rest of Mountain Time does.

Matt Johnson-Pint
  • 230,703
  • 74
  • 448
  • 575
  • The main question is, can you make a global USA ranking? In what moment you need to reset the counters? – SeViR Nov 16 '18 at 19:04
  • Not really. You'll have to do it separately for each time zone. If all you have is the country, then you don't have enough information to know precisely when their day (or week) starts. Perhaps you can determine their time zone from other information you may have? For example [from lat/lon](https://stackoverflow.com/q/16086962/634824) of their location? – Matt Johnson-Pint Nov 16 '18 at 19:39
  • Otherwise, you'd just have to pick the first time zone (chronologically) that matters to you, and align to that one - being slightly inaccurate is sometimes ok, depending on what you're doing. – Matt Johnson-Pint Nov 16 '18 at 19:40
  • So, I think that I have only a few options for equality: reset all country rankings one time in 00:00 UTC or mantain one global ranking. – SeViR Nov 16 '18 at 20:28
  • If it helps you decide, consider Stack Overflow's stats rankings are all reset daily at 00:00 UTC. Though your situation may vary. If you're just targeting the continental US, maybe reset at 00:00 Eastern time. Keep in mind Eastern will vary depending on if DST is in effect or not (UTC-5 vs UTC-4). – Matt Johnson-Pint Nov 16 '18 at 20:44