Fun with time zones and time ranges

I'm posting this here for folks because I don't have a blog. Had to write some code to figure out whether we were within acceptable hours for contacting customers and within customer support hours.

Some of the biggest obnoxious bits surrounded constructing times in the correct timezones for a given date with all the correct offsets including DST.

I initially tried constructing a timedate from scratch including the offset, but realized if that date was not today, I still needed a timedate on the correct date to determine if DST was active. So the "tz_offset" function is now dead code, but it shows constructing a timezone offset given a date and timezone. Hopefully this code will be helpful to someone.

    def date_to_day(date, zone)
      [date.at_beginning_of_day.in_time_zone(zone), date.at_end_of_day.in_time_zone(zone)]
        .detect { |t| t.to_date == date }
        .at_beginning_of_day
    end

    def tz_offset(date, zone)
      time = date_to_day(date, zone)
      ActiveSupport::TimeZone[zone].at(time).formatted_offset
    end


   def time_range_on_date( date, zone, start_hour, end_hour)
     day = date_to_day(date, zone)
     (day + start_hour.hours)..(day + end_hour.hours)
   end

  def time_from_date(date,zone)
    TimeDate.new( date.year, date.month, date.mday, 0, 0, 0, tz_offset(date,zone))
  end
πŸ‘︎ 6
πŸ“°︎ r/ruby
πŸ’¬︎
πŸ‘€︎ u/ikariusrb
πŸ“…︎ Oct 02 2019
🚨︎ report
Time Zone Poll

Hi guys,

DON'T FORGET TO CLICK ON THE POLL GUYS. COMMENTING YOUR ZONE HERE WON'T HELP, SO CLICK ON THE POLL!

I want to be able to accommodate your schedules as best as possible. I plan to hold discussion threads after each lecture, but I want those of your outside of the U.S. to be able to participate as well. As such, please refer to the map and select your time zone. You can do this by locating your country and identifying the color. Try to match it with the time zone. Zones are matched on color, so if your country straddles two lines, look at the color and find a location in that area with that color and an associated zone label. For example, France is in line Z, but it is blue. Therefore, it is zone A. Once you know your time zone (for instance, I live on the east coast of the US, so my time zone is R) go to this poll and select which time zone you live in. I'll try to schedule discussion threads at times when everyone can participate.

EDIT: Added clarification on how to find time zone.

πŸ‘︎ 59
πŸ“°︎ r/IntroPsych
πŸ’¬︎
πŸ“…︎ Aug 21 2012
🚨︎ report
LPT- You may not like being in pictures or taking them, but you will hate that you have no photos of some time period when you’re older. Take pictures even if it is out of your comfort zone occasionally, for your future self.

My wife has taken hundreds of pictures throughout our marriage and I only recently started. She has basically documented the whole time we’ve been together and I am extremely grateful for it. She has pictures from the day we met that we wouldn’t have if she didn’t snap a quick β€˜for memories’ picture. You may hate the way you look, but years from now you will be glad you ignored that and took a photo.

I also want to comment on the people who said β€˜people didn’t always have technology’. That is a horrible excuse to not preserve memories. Because you’re too old fashioned? Cameras are a century and a half old at this point. You’re just being stubborn and pseudo β€˜mystical’ to say you want to cherish the β€˜spirit of the memories’ and never take a single picture. Lots of tech was lived without a long time ago but using it as a tool and not a crutch can bring us closer together as people and as a family.

πŸ‘︎ 76k
πŸ“°︎ r/LifeProTips
πŸ’¬︎
πŸ“…︎ Apr 07 2021
🚨︎ report
[McFadden] I was stunned to hear this from Teddy Bridgewater, speaking about his time in Carolina..."One of the things we didn't do much of when I was there, we didn't practice 2-minute really, we didn't practice red zone." twitter.com/BMac_SportsTa…
πŸ‘︎ 2k
πŸ“°︎ r/nfl
πŸ’¬︎
πŸ‘€︎ u/RedFredTV
πŸ“…︎ May 12 2021
🚨︎ report
Time zones are amazing
πŸ‘︎ 53k
πŸ’¬︎
πŸ‘€︎ u/DaFunkJunkie
πŸ“…︎ Apr 17 2021
🚨︎ report
Our ultimate stealth camper truck... Been full time for 6 months now, never had a knock, could park in a loading zone and not be questioned haha reddit.com/gallery/my6f54
πŸ‘︎ 10k
πŸ“°︎ r/vandwellers
πŸ’¬︎
πŸ“…︎ Apr 25 2021
🚨︎ report
Stupid time zones.
πŸ‘︎ 4k
πŸ“°︎ r/Grimdank
πŸ’¬︎
πŸ‘€︎ u/HobbyistAccount
πŸ“…︎ May 14 2021
🚨︎ report
[McFadden] I was stunned to hear this from Teddy Bridgewater , speaking on his time in Carolina... β€œOne of the things we didn’t do much of when I was there, we didn’t practice 2-minute really, we didn’t practice red zone.” Full interview twitter.com/bmac_sportsta…
πŸ‘︎ 106
πŸ“°︎ r/panthers
πŸ’¬︎
πŸ‘€︎ u/jcoles0417
πŸ“…︎ May 12 2021
🚨︎ report
TIL Despite the fact that China is wider than the contiguous United States and could ideally have 5 different time zones, China uses only one time zone called China Standard Time (CST) across the entire country. infobloom.com/why-does-ch…
πŸ‘︎ 2k
πŸ“°︎ r/todayilearned
πŸ’¬︎
πŸ‘€︎ u/standbylion8202
πŸ“…︎ Apr 06 2021
🚨︎ report
Valkyrie aside, this is the best countdown I have ever seen on any video premiering on YouTube. Of course I haven't seen previous ones due to time zone (or laziness) but I hope to see more of this for the next premier. Keep it up Respawn.
πŸ‘︎ 4k
πŸ“°︎ r/apexlegends
πŸ’¬︎
πŸ‘€︎ u/Olly_Joel
πŸ“…︎ Apr 19 2021
🚨︎ report
[15F] Hey, I’m Jessie. I’m bi and I use she/they pronouns. I like skating, baking, watching true crime/horror stuff, listening to podcasts, and other stuff. I’m on pacific time so please only similar time zones. Anyone 15-17 can message! reddit.com/gallery/n9synu
πŸ‘︎ 183
πŸ“°︎ r/TeensMeetTeens
πŸ’¬︎
πŸ“…︎ May 11 2021
🚨︎ report
Kaiserslautern, a German Club who has won the Bundesliga 4 times most recently in 97/98 is currently fighting for their lives to not get relegated to the German 4th tier. They are currently in the relegation zone of goal difference
πŸ‘︎ 732
πŸ“°︎ r/soccer
πŸ’¬︎
πŸ‘€︎ u/mothman26
πŸ“…︎ Apr 20 2021
🚨︎ report
β€œTHINK CONQ! HOW CAN YOU ZONE 14 TIMES AND EXPECT TO WIN??”
πŸ‘︎ 968
πŸ“°︎ r/forhonormemes
πŸ’¬︎
πŸ‘€︎ u/Cadenot6
πŸ“…︎ May 08 2021
🚨︎ report
It has been an exhausting hardening off process in zone 6a, with spring 1.0, winter 3.0, and spring 2.0, but despite the trips in and out, I am so happy with how these turned out. My first time starting tomatoes from seed.
πŸ‘︎ 648
πŸ’¬︎
πŸ‘€︎ u/RMD129
πŸ“…︎ Apr 26 2021
🚨︎ report
How do TV stations manage time zones?

Hi guys, just wondering if popular, nationwide shows are shown at the same time across the US, or if they make each time zone wait until 9pm, say.

I live in the UK, and towards the end of Game of Thrones (in an effort to lessen piracy) they used to broadcast it here at 2am (9pm ET), then again at 9pm the next night, for all of the normies who aren't going to sit up till a ridiculous time.

EDIT: Thank you for the replies.

πŸ‘︎ 83
πŸ“°︎ r/AskAnAmerican
πŸ’¬︎
πŸ‘€︎ u/WolfLoverBlack
πŸ“…︎ May 11 2021
🚨︎ report
β€œThink conq! How can you zone 14 times and expect to win?!”
πŸ‘︎ 482
πŸ“°︎ r/forhonor
πŸ’¬︎
πŸ‘€︎ u/Cadenot6
πŸ“…︎ May 09 2021
🚨︎ report
My favourite time in WoW's history was in Cataclysm, when Deathwing would fly over a zone and kill everyone.

I know that a lot of people hated it, but I absolutely loved it when the zone I was in was targeted by Deathwing, and was doomed. The sky turned red, fire was everywhere. There was no way to avoid it. When Deathwing flew over the zone, everyone died.

πŸ‘︎ 600
πŸ“°︎ r/wow
πŸ’¬︎
πŸ‘€︎ u/maybepants
πŸ“…︎ Apr 13 2021
🚨︎ report
Dear Blizzard! Changes like the one related to Blazing Ingots wont make me spend more time with your game, you will just make me skip an entire zone.

I see that people already stated that they do not want this change and that this quest takes forever to complete now. The problem is not just this quest, but the entire Maw now.

You can say that we have to struggle there because that's the lore of the whole place... but man. It already had plotholes all over the thing. My mount is too affraid to hear my calling, but my battle pets has balls of steel. My divine steed from "paladin quest" can't be summoned, but it's fine if he is summoned from a skill, the death elemental has PTSD and do not want to be summoned at home and so on... I think we can safely say that these things about the quests wont be the problems lore wise.

The Maw itself feels like a chore and it offers almost 0 rewards for spending time there. Hell, even the elites are boring cause they have no purpose except farming them for stygia.

You just do not want to spend time there... I for example was lucky enough to get a shadehound from the hunt quest, so I didn't had to farm TW for that. When the mount dropped I was so happy that I will be able to mount up in the maw and started to imagine myself actually spending time in the maw.

I was wrong... Even with my mount it still feels terrible and I still go and grab the souls and say good bye to the Maw for the entire week.

So, I'm already spending the minimum time there and only go once after a reset and you think that changes like these will keep me in that zone? Why do not you put some effort into the Maw and... I do not know... put actual events, cosmetic rewards and so on inside the zone? Hell, maybe I would even farm for powers which I can use in Torghast.

With these changes you will just take an entire zone out of the content.

Tl.dr.: What we need in the Maw is content, not chores to keep us there.

πŸ‘︎ 2k
πŸ“°︎ r/wow
πŸ’¬︎
πŸ‘€︎ u/Athem
πŸ“…︎ Mar 17 2021
🚨︎ report
One of these things is NOT like the others(& how Supercell can fix matchmaking across multiple time zones)
πŸ‘︎ 221
πŸ“°︎ r/ClashRoyale
πŸ’¬︎
πŸ‘€︎ u/Bennyscrap
πŸ“…︎ May 11 2021
🚨︎ report
You will never regret putting in fruit trees. Best time to plant was 6 years ago! Zone 8b Olympic Peninsula. reddit.com/gallery/mt4vsb
πŸ‘︎ 993
πŸ“°︎ r/homestead
πŸ’¬︎
πŸ“…︎ Apr 18 2021
🚨︎ report
Reposting my Fibonacci Time Zone TA from April 24th since my prediction is looking more accurate
πŸ‘︎ 442
πŸ“°︎ r/Superstonk
πŸ’¬︎
πŸ‘€︎ u/WarioFangirl68
πŸ“…︎ Apr 28 2021
🚨︎ report
I’ve been putting a lot of time into creating the actual world for Wrath Of The Mad King. Tried to give each zone their own look. Always open to new zone ideas! v.redd.it/kcb8a4g66av61
πŸ‘︎ 441
πŸ“°︎ r/IndieGaming
πŸ’¬︎
πŸ‘€︎ u/Husmanmusic
πŸ“…︎ Apr 25 2021
🚨︎ report
A map of the world but it’s just the time zones.
πŸ‘︎ 30k
πŸ“°︎ r/MapPorn
πŸ’¬︎
πŸ‘€︎ u/boldvinaxc
πŸ“…︎ Feb 02 2021
🚨︎ report
Turning Kenly College into a Dark Zone has been one of the best design choices Massive has made in a long time.

Sorry if I'm late to the party, I havent played in a month or so. Logged on today and accidently fast traveled to Kenly instead of Summit. Blew my mind when I saw they changed it all up. I'm normally half and half when it comes to enjoying the DZs but damn if the chaos on campus didnt hit different. The population felt perfect. It never felt barren like some DZ runs in the normal 3 but it also never felt too crowded or saturated by rigged teams of 6 etc. Each wing felt better than the last. The loot, after a couple hours, was still sub-par for needing to extract but the enjoyment level made it well worth it. This is hands down the most fun ive had in pvp for the entire franchise. I think the best part was the new Key Card mechanic when extracting. Hitting all 3 extraction points successfully to unlock the "Diamondback Crypt" door was a nice twist. I was very surprised when I opened it to find out this whole post was just an April fools and Kenly is still Kenly unfourtantly. Sorry agents, I'll see myself out now.

Edit: Sorry suckahs. Also, get bent Carnage_By_Boris. Go [REM]. PiperDog, best dog.🀘 Westep23 is legend.

πŸ‘︎ 1k
πŸ“°︎ r/thedivision
πŸ’¬︎
πŸ‘€︎ u/Mithmorthmin
πŸ“…︎ Apr 01 2021
🚨︎ report
/r/BoneAppleTea Is Looking For Additional Moderators From All Time Zones!

Edit: Applications are now closed. Thanks for applying!

Hello /r/BoneAppleTea! It's that time of the year where we're looking to expand our team of volunteers that help keep this place running. /r/BoneAppleTea has continued to grow at a healthy rate and coupled with inevitable moderator discharges, we find ourselves needing to recruit to not only keep up but actually get ahead of the mounting challenge that comes with moderating.

We are currently looking for moderators of all time zones. We have a particular interest in people who can cover every time zone.

No matter the country you live in or the hours you're active, if feel like you would be a good addition to our mod team then please read on and, if all sounds good, submit an application!

Below, we've included a list of requirements and preferred qualities we're looking for in our applicants.

Requirements:

  • You must read the rules carefully and acquire a good understanding of them before applying.
  • Power mods/subreddit collectors need not apply. Most if not all of our moderators only moderate /r/BoneAppleTea, or one or two other big-sized subreddits. We have no interest in subreddit collectors. That being said, you can still apply if you think you can spare an adequate amount of time moderating /r/BoneAppleTea.
  • We expect a good degree of activity. We do not benefit from recruiting new mods that are of low activity from the beginning. We will monitor your mod activity on a regular basis and revoke your mod status if you fail to contribute to moderation during the trial or later periods.
  • You must be able to coordinate with the rest of the moderation team while you are moderating. We use Discord for team discussions and communicating when you will be away for extended periods of time.
  • Your Reddit account must be at least 6 months old and has a minimum of 1500 combined karma.
  • You must be willing and able to put a decent amount of time into moderating on /r/BoneAppleTea.
  • You must be comfortable going through a trial period after which we will gradually increase your mod permissions depending on the degree of your mod activities.
  • We expect applicants to be familiar with the /r/BoneAppleTea community, but we do not require moderators to be actively posting.
  • You must have a decent history of comments/posts. We will individually examine the post history of every applicant. Any content that may hold an unpopular opinion in your post history is a death sentence.
  • The fact that you were ban
... keep reading on reddit ➑

πŸ‘︎ 772
πŸ“°︎ r/BoneAppleTea
πŸ’¬︎
πŸ‘€︎ u/Sapotis
πŸ“…︎ Apr 22 2021
🚨︎ report
Man the curse of being in a completely different time zone
πŸ‘︎ 2k
πŸ’¬︎
πŸ‘€︎ u/_Shoulder_
πŸ“…︎ May 05 2021
🚨︎ report
[MLBRandomStats] Lost in the Ohtani insanity: Mike Trout swung at a 3-0 pitch that was out of the strike zone for the first time in nearly five years (May 7, 2016). twitter.com/mlbrandomstat…
πŸ‘︎ 2k
πŸ“°︎ r/baseball
πŸ’¬︎
πŸ‘€︎ u/TheDangiestSlad
πŸ“…︎ Apr 05 2021
🚨︎ report
Episode 3 airing tomorrow (depending on time zone) v.redd.it/p7kwvhvlywu61
πŸ‘︎ 567
πŸ“°︎ r/nagatoro
πŸ’¬︎
πŸ“…︎ Apr 23 2021
🚨︎ report
Trying to eat healthier. First time Bountiful Baskets co-op haul. Paid $34.02USD. Good or bad price in your opinion? Either way, this is helping me get out of my comfort zone. I eat way too much junk.
πŸ‘︎ 215
πŸ“°︎ r/PlantBasedDiet
πŸ’¬︎
πŸ‘€︎ u/MaiaOnReddit
πŸ“…︎ Apr 23 2021
🚨︎ report
Watching a Dodger get his first Major League hit while eating breakfast? It's a Belgian (time-zone) thing! Go Blue! βšΎοΈπŸ‡§πŸ‡ͺ
πŸ‘︎ 780
πŸ“°︎ r/Dodgers
πŸ’¬︎
πŸ‘€︎ u/AmericanFrog069
πŸ“…︎ Apr 15 2021
🚨︎ report
Tales from the Quadead Zone (1987). Copy of infamous African-American director Chester Novell's Turner straight-to-VHS blaxploitation horror cult classic. Likely one of the worst movies I've seen in a long time. youtu.be/y4iNisEvfoE
πŸ‘︎ 250
πŸ“°︎ r/ObscureMedia
πŸ’¬︎
πŸ‘€︎ u/tjcf2014
πŸ“…︎ May 06 2021
🚨︎ report
This is her favorite time of the year. πŸ’• (Desert Rose, Zone 9B)
πŸ‘︎ 1k
πŸ“°︎ r/plants
πŸ’¬︎
πŸ‘€︎ u/QueerKinkyPoly
πŸ“…︎ Apr 19 2021
🚨︎ report
*Cries in Asian time zone*
πŸ‘︎ 499
πŸ“°︎ r/destiny2
πŸ’¬︎
πŸ‘€︎ u/anangrypudge
πŸ“…︎ May 13 2021
🚨︎ report
How do you cope with the time zone problems? Drop any tips you have, below!
πŸ‘︎ 486
πŸ“°︎ r/LongDistance
πŸ’¬︎
πŸ‘€︎ u/msaad99
πŸ“…︎ Apr 19 2021
🚨︎ report
Im so excited for the show and, because of my time zone, I will be getting the sneak peak tomorrow morning and the show in the afternoon yiieeee!
πŸ‘︎ 442
πŸ“°︎ r/Grishaverse
πŸ’¬︎
πŸ‘€︎ u/soapsoapsoap07
πŸ“…︎ Apr 22 2021
🚨︎ report
This is her favorite time of the year. πŸ’• (Desert Rose, Zone 9B)
πŸ‘︎ 656
πŸ“°︎ r/gardening
πŸ’¬︎
πŸ‘€︎ u/QueerKinkyPoly
πŸ“…︎ Apr 19 2021
🚨︎ report
Overwintered Habanero going outside for the first time this year. Zone 5b.
πŸ‘︎ 233
πŸ“°︎ r/HotPeppers
πŸ’¬︎
πŸ‘€︎ u/happybopappy
πŸ“…︎ May 02 2021
🚨︎ report
[WP] Time zones actually do transcend time. England is 5 hours into the future ahead of the US East Coast, and so on. Things work reasonably well, all things considered, until we begin to lose communication with the nations in each time zone as they hit a specific time, with no clue as to why.
πŸ‘︎ 535
πŸ“°︎ r/WritingPrompts
πŸ’¬︎
πŸ‘€︎ u/sofascientist
πŸ“…︎ May 09 2021
🚨︎ report
XBOX Weekly Treasure is up on the 10th May 2021 (Monday) in your respective time zone

Remember to sign in to your Xbox and claim this 100 points within the MS Rewards App.

Cheers!

πŸ‘︎ 176
πŸ“°︎ r/MicrosoftRewards
πŸ’¬︎
πŸ‘€︎ u/dynamite_dilly
πŸ“…︎ May 09 2021
🚨︎ report
Didn't know that Pierre dropped by time zones
πŸ‘︎ 43
πŸ“°︎ r/playboicarti
πŸ’¬︎
πŸ‘€︎ u/Mannihorst
πŸ“…︎ May 12 2021
🚨︎ report
BEN 1ST PZ Class | Date Fri 4/30/21 | Time (9:00 AM) | 30 min Power Zone Ride | BEN ALLDIS

Let's join Ben Alldis as he kicks off his first live Power Zone class!

Comment below if you can make it.

Class Link | My Profile

I will edit this post with who's participating.

Confirmed:

alexrodriguez

DenimDaisy26

meneIik

DesiiGirl

Kristen_eden

stellathediver

_bluetree

magichours

Plodly

JimBag

Pelo_PMae

KesselRun4Fun

Pedalsfor_Pinot

GoBlueNP

πŸ‘︎ 47
πŸ“°︎ r/pelotoncycle
πŸ’¬︎
πŸ‘€︎ u/iAm22lr
πŸ“…︎ Apr 29 2021
🚨︎ report
Depends on your time zone
πŸ‘︎ 199
πŸ“°︎ r/PrequelMemes
πŸ’¬︎
πŸ‘€︎ u/SCLizardman
πŸ“…︎ May 05 2021
🚨︎ report
Hi friends! I'll stream at r/whereintheworld tomorrow (Sat) at 3PM JST. Your local time zone can be found in the comments below! See you there!
πŸ‘︎ 158
πŸ’¬︎
πŸ‘€︎ u/eigo-ha-no-desu
πŸ“…︎ May 14 2021
🚨︎ report
First time flying out of the planets orbital zone without supercruise. Did it in my 900 m/s topspeed viper mk III inspired by the BLU Lightning ship
πŸ‘︎ 115
πŸ“°︎ r/EliteDangerous
πŸ’¬︎
πŸ‘€︎ u/MasterMysterie
πŸ“…︎ May 10 2021
🚨︎ report
Time zones man...
πŸ‘︎ 4k
πŸ“°︎ r/Hololive
πŸ’¬︎
πŸ‘€︎ u/cnlu77
πŸ“…︎ Mar 31 2021
🚨︎ report
4 employees, 2 different time zones, is 24/7/365 operation possible?

I manage a L2/L3 team and we need to setup 24/7/365 operation in the very near future. 2 employees are in the eastern time zone, 2 are in the Moscow time zone (+7 from EDT at the moment). Proposed shifts are as follows (All times EDT):

Morning - 12:00am to 9:00am
Day - 8:00am to 5:00pm
Evening - 4:00pm to 1:00am

The above shifts are flexible, I kicked around 8 / 8 1/2 hour shifts, however with a full 9 hours I can give 1 full hour for lunch (though we would need coverage during that time). I was thinking weekend shifts could switch to two shifts of 12 hours each, whatever keeps us close to the 40-45 hours per week (OT is possible as well).

Is there any way to do this with the above? The schedules I've come up with to this point have had a shortfall somewhere (due to balancing hours and making sure no one works the overnight in their time zone). I take it I would need to hire additional staff? With 5 employees I can make it work, but still be vulnerable for vacation time, and/or sick days, etc.

I'm hoping someone out there is familiar with this sort of schedule, I feel the additional time zones adds complications to the whole thing. I've tried shift scheduling apps/sites, however they haven't been able to help either.

Any help is appreciated, thanks in advance!

πŸ‘︎ 4
πŸ“°︎ r/sysadmin
πŸ’¬︎
πŸ‘€︎ u/RavN0uS
πŸ“…︎ May 10 2021
🚨︎ report
Gianforte signs daylight savings bill; states to petition feds for permanent time zone missoulacurrent.com/monta…
πŸ‘︎ 45
πŸ“°︎ r/MontanaPolicy
πŸ’¬︎
πŸ‘€︎ u/fatalexe
πŸ“…︎ May 12 2021
🚨︎ report
Struggles of being an Aussie Eurofan #1 time zones
πŸ‘︎ 26
πŸ“°︎ r/eurovision
πŸ’¬︎
πŸ‘€︎ u/imalittlespider
πŸ“…︎ May 14 2021
🚨︎ report
Every time i have to zone toys haha
πŸ‘︎ 345
πŸ“°︎ r/walmart
πŸ’¬︎
πŸ‘€︎ u/jonfreakin
πŸ“…︎ Apr 25 2021
🚨︎ report

Please note that this site uses cookies to personalise content and adverts, to provide social media features, and to analyse web traffic. Click here for more information.