# Golf Me a World Clock 🌐🕖

Write a program or function that takes as input a time in UTC, and outputs the equivalent time in 5 different cities around the world. The cities displayed are up to the programmer, but the time must be different in each city.

To prevent golfers from using overly obscure city names, the city names used must appear on this list: World Cities*, which corresponds to the list of cities and times found here.

As usual, Standard loopholes are forbidden, including fetching data from an external source.

*The times provided in the pastebin use daylight time and assume that the time is 0:30 UTC.

### Example

Given as input 12:30AM, your output might be:

Athens: 3:30AM
London: 1:30AM
New York: 8:30PM
Seoul: 9:30AM
Beijing: 8:30AM


### Input

You may take input in any reasonable format. You can choose to take the time as 24-hour time, or 12-hour time with AM and PM. Specify the input format in your answer.

### Output

Output may also be in either 12-hour or 24-hour time. The city-time pairs may be in any order and any reasonable format, so long as it is possible to associate each city with the corresponding time.

Daylight Savings Time can safely be ignored (ie. you can either use the offsets from the pastebin above, or you can assume that all times are in daylight time, or alternatively all in standard time)

### Scoring

This is . Happy golfing!

• What is the format of the pastebin file? For instance, what does "London, 01:30" mean? (If DST are ignored, London should be UTC+0.) May 15 '20 at 18:06
• @Arnauld Ah yes, the pastebin times use daylight time and are in reference to UTC 0:30. I'll specify that in the question May 15 '20 at 18:09
• So, should we ignore the times in this file and just use it as a list of allowed cities? May 15 '20 at 18:12
• @Arnauld Yes, you can ignore the times in that file. They might be useful to calculate the offset from UTC for a given city though May 15 '20 at 18:14
• kyiv lima rome oslo suva doha is what everyone will do, just making it simpler.
– Wezl
May 15 '20 at 18:20

# Python 2, 8079 77 bytes

-1 byte thanks to Surculose Sputum.

24-hour time, input as hours, minutes.

h,m=input();i=h


Try it online!

Example output for 0, 30 (12:30AM):

Accra 0 30
Lagos 1 30
Cairo 2 30
Amman 3 30
Dubai 4 30

• 79 bytes May 15 '20 at 18:51
• @SurculoseSputum thanks a lot. For some reason I thought I need an additional UTC+5 city.
– ovs
May 16 '20 at 9:51
• 72 bytes by moving cities to input('...') prompt, albeit at the cost of readability. AccraLagosRomeKyivDubai can save another two. May 16 '20 at 15:32
• @Duncan thanks for the suggestion, but I feel like this will be too similar to the other Python answer.
– ovs
May 16 '20 at 16:46

# Python 2, 71 65 bytes

Save 2 bytes using @dingle dooper's printing through input() trick!

t=input('Accra Lagos Rome Kyiv Dubai ')
exec"print t%24,;t+=1;"*5


Try it online!

Takes input as a complex number (e.g 01:30 is inputted as $$\1+30i\$$), and prints out the list of cities, then the corresponding times. Uses 24-hour time.

• The spaces could be left out, saving 5 bytes, and the comma in print t%24, can also be left out for another 1 byte May 16 '20 at 15:41
• @Duncan thanks! It seems like most answer does have separator between city names and times, so I'll keep the spaces for now. May 17 '20 at 1:55

for c in Amman Dubai Kabul Dhaka Seoul;{ TZ=Asia/$c date +$c\ %R -d$1Z;}  Try it online! Input is passed as an argument, and output is on stdout. Both are in 24-hour time. # Google Sheets, 8277 80 bytes Saved 5 bytes by finding a shorter list of city names that are all off by 1 hour. Added 3 bytes thanks to Surculose Sputum pointing out that I was referencing the wrong list. =ArrayFormula(Split("Lagos,Rome,Kyiv,Dubai,Kabul",",")&Mod(A1+Column(A:E),24)&B1  Sheets will automatically add the trailing parentheses. Hours are input in A1 and minutes in B1. Split(~) gives us the list of city names. A1+Column(A:E) iterates the input time by ones. Mod(~,24) accounts for when the clock rolls to the next day. Split(~)&Mod(~)&B1 tacks on the minutes. ArrayFormula(~) makes the whole thing work on arrays instead of just the first value. There aren't any delimiters between the city name and the time because pretty costs bytes. It's fairly easy to distinguish between the end of the name and the start of the time, though, since none of the city names have numbers in them. • @SurculoseSputum Could you be more specific? All 5 listed appear in OP's list of allowed cities. May 18 '20 at 16:01 • @SurculoseSputum My apologies. I had gotten the two lists confused in my copies. I have corrected the city names now. Thank you. May 18 '20 at 17:40 # 05AB1E, 25 bytes Thanks to Kevin Cruijssen for shaving off 7 bytes. ”Accra‡¸«ÄçªâÈ”#ε¹N+24%²»  Try it online! # 05AB1E, 32 bytes Just another port of Surculose Sputum's answer. It produces quite an ugly output, due to joining by newlines. ”Accra Lagos«Ä KyivâÈ”#ε¹N+24%²»  Try it online! # Explanation (for both) ”...” Compressed string with the cities # Space-split ε Map: Implicit current city pushed ¹ First input: N+ Add by the iteration counter 24% Modulo by 24 ² Append the second input » Join the whole stack by newlines.  • -2 byte using a compressed string instead of dictionary string: .•Eān³ûζǝ₃δb¶«Ív¢L•™ May 18 '20 at 6:51 • 25 bytes by using London and Baghdad instead of Lagos and Kyiv, which are part of the dictionary. May 18 '20 at 6:58 # Befunge-93, 238 bytes &&\" arccA",,,,,,:.\:.\" nammA",,,,,,3+:345*+!v v < > v v +*543:+3,,,,,,"Dhaka "\.:\.:_#<83*-^ ^-*38>#_ :.\:.\" luoeS",,,,,,3+:345*+!v v < > v v +*543:+3 ,,,,,"Suva " \.:\.:_#<83*-^ ^-*38>#_:.\:.@  Try it online! Reads the hour and minutes from the input. For each city, except the first, it adds 3 to the hour, then checks whether it exceeds 23. If it does, it makes a small loop to subtract 24. The rest is just printing strings, moving the PC around and swapping the hours/minute to/from the top of the stack. • You can take the input in reverse order, removing the need for the initial swap: tio.run/##S0pNK81LT/3/… – ovs May 16 '20 at 16:49 • And the subtract 24-part for Amman can be moved to the front: tio.run/##S0pNK81LT/3/…. The same may be possible for Suva, but this is a little bit trickier – ovs May 16 '20 at 16:57 # C (gcc), 92 bytes i;f(h,m){for(i=0;i<5;)printf("%s %d:%d;","AccraLagosRome.Kyiv.Dubai"+6*i++,(h+i)%24,m);}  Try it online! Port of Bash, didn't check map # C (gcc), 94 bytes i;f(h,m){for(i=0;i<15;i+=3)printf("%s %d:%d;","AccraAmmanDhakaSeoulSuva"+2*i,(h+i)%24,m);}  Try it online! Port of Python solution, didn't check map # Jelly, 23 bytes +Ɱ5%24;€⁹“F=ẓŒMdƲEṢ$Ṛ.»


A full program accepting two arguments, hours then minutes, which prints in an ugly format. Uses Algiers Amsterdam Amman Dubai Islamabad since they are the alphabetically earliest allowed cities with DST offsets of 1-5 hours from UTC.

Try it online!

### How?

+Ɱ5%24;€⁹“F=ẓŒMdƲEṢ$Ṛ.» - Main Link: hour, H; minute M Ɱ5 - map across [1..5] with: + - addittion (to H) %24 - modulo by 24 ⁹ - chain's right argument, M ;€ - concatenate to each “F=ẓŒMdƲEṢ$Ṛ.» - compressed string "Algiers Amsterdam Amman Dubai Islamabad"
-   (this new niladic chain forces the previous result to be printed)
- implicit print


# Bash, 118 $$\\cdots\$$ 76 75 bytes

Saved a byte thanks to Duncan!!!
Saved a whopping 18 39 41 42 bytes thanks to David G.!!!

# PHP 5.4+, 96 bytes

Yes, it's a fat boy :(
But was fun to write it!

foreach([Accra,Lagos,Cairo,Doha,Dubai]as$k=>$v)echo"\n$v ",date(H_i,strtotime("$argn {$k}hour"));  Run this with php -r (produces warnings). The input format is flexible, as long as it can be interpreted by strtotime(). You can input hours in 12-hour or 24-hour formats, being displayed in 24-hour format. The cities chosen were picked because they are NOT in DST at the time of this answer: # JavaScript (V8), 81 bytes (h,m)=>'Accra-Lagos-Rome-Kyiv-Dubai'.split-.map(e=>console.log(e,h++%24+':'+m))  Try it online! • Wow - first time I seen this syntax of avoiding parentheses on the split function. Can you provide some reference? May 18 '20 at 15:33 • I think this way you can call any function with one parameter. May 18 '20 at 15:42 • @AnArrayOfFunctions The syntax used in the .split is allowed when you have a template string (the string with the accent character) as the only argument, which allows you to remove the parenthesis. However, using a number, in this case, removes the need for the template string. As I've suggested to another answer, using 'Accra0Lagos0Rome0Kyiv0Dubai'.split(0) has the same exact size, but is easier to read and understand what's going on. May 19 '20 at 8:47 # JavaScript, 65 bytes Input f(h)(m). Outputs an array of arrays: [[City, mm, ss], ...]. h=>m=>Accra Lagos Rome Kyiv Dubai.split .map(c=>[c,h++%24,m])  Try it online! # JavaScript, 66 bytes Prettier. Outputs a string with City,mm,ss separated by newlines. h=>m=>Accra Lagos Rome Kyiv Dubai.replace(/.+/g,M=>[M,h++%24,m])  Try it online! # JavaScript, 64 bytes Uglier. Outputs a string without delimiters: Citymm,ssCitymm,ss.... h=>m=>Accra Lagos Rome Kyiv Dubai .replace(/ /g,_=>[h++%24,m])  Try it online! # Charcoal, 38 bytes Ｅ⪪”↶+∧e-|GT⊘"↘w⌊⎇*↔ＪAN·”⁵⪫⟦ι﹪⁺Ｉθκ²⁴η⟧  Try it online! Link is to verbose version of code. Port of @SurculoseSputum's Python answer. Takes input as separate hours and minutes and uses the 24 hour clock. Explanation:  ... Compressed string of five cities ⪪ ⁵ Split into substrings of length 5 Ｅ Map over each substring ι Current substring Ｉθ Input hours as a number ⁺ κ Plus current index ﹪ ²⁴ Modulo literal 24 η Input minutes ⪫⟦ ⟧ Joined with spaces Implicitly print on separate lines  # W, 33 bytes Just realized that my language is such a bad language. It doesn't even support dumping the stack... ☻|▓■°u:"≡∟◘Σ≡☺╖ⁿ╩]┼ε╝╣╗à_∙▬Cô\K←û  Uncompressed: "3@374Ry<+o;<r>YwI+eA78P5a(c0[+24mc1[{M  ## Explanation "3@374Ry<+o;<r>YwI+eA78P % Compressed string containing the cities 5 M % In the range 1..5: a % The current counter, ( % Decremented, c0[+ % Is added to the hours 24m % And modulo'd by 24 c1[ % Push the minutes { % Pair the two items  # C# (Visual C# Interactive Compiler), 119 bytes Input: hh:mm Output: h:mm t=>String.Concat("Accra,Lagos,Rome,Kyiv,Dubai".Split(',').Select((c,i)=>c+$":{(int.Parse(t[0..2])+i)%24}:{t[3..5]}\n"))
`

Try it online!