[Question]
  [
I can have a large `if/else` condition for each 30 minutes but I'm looking for more math and Unicode based solution.
Here are clock emojis:
üïêüïëüïíüïìüïîüïïüïñüïóüïòüïôüïöüïõüïúüïùüïûüïüüï†üï°üï¢üï£üï§üï•üï¶üïß. If you lack proper rendering support, you can see them below (they're not in the same order and they may look different to what you see) or at [the Unicode chart](http://www.unicode.org/charts/PDF/U1F300.pdf), page 4. They correspond to Unicode codepoints U+1F550 (CLOCK FACE ONE OCLOCK) through U+1F567 (CLOCK FACE TWELVE-THIRTY).
Your challenge is to write a program that outputs to STDOUT the closest clock face emoji to the current system time (AM and PM should be treated the same). For example if the time `t` is [5:15 ‚â§ t < 5:45), you would display the 5:30 emoji üï†.
This is code-golf, so shortest code in bytes wins. You may want to include a way to easily specify the time to test your code.
# Edge test cases
```
Time   Output  Written
----------------------
11:48  üïõ       12:00
3:15   üïû       3:30
9:45   üïô       10:00
```
![enter image description here](https://i.stack.imgur.com/aka7v.png)
  
[Answer]
# Ruby ‚Äî ~~61~~ 54 bytes
# ~~Python 3 ‚Äî 79 77 75 74 bytes~~
**edit:** Turns out this is much shorter in Ruby, because `Time` doesn't need to be imported and integer division is the default.
```
a=(Time.now.to_i/900-3)/2%24
puts""<<128336+a/2+a%2*12
```
Arithmetic:
* `Time.now.to_i`: Seconds since epoch.
* `/900`: Combine time into 15-minute segments.
* `-3`: `-4` because characters start at 1 o'clock, `+1` so that rounding is done to nearest half hour, rather than downwards.
* `/2`: Combine into half-hour segments.
* `%24`: Get current half-hour segment out of 12 hours.
* `a/2 + a%2*12`: Account for the fact that whole-hour characters come in a block before half-hour characters.
**Local time version, 69 bytes:**
```
n=Time.now
a=((n.to_i+n.gmtoff)/900-3)/2%24
puts""<<128336+a/2+a%2*12
```
**Original Python 3 version:**
```
import time
a=int((time.time()/900-3)/2%24)
print(chr(128336+a//2+a%2*12))
```
Prints the current time UTC. Python 2's `chr` only accepts 0-255, and `unichr` only 0-65535. In Python 3, `/` is always floating-point division and `//` is always integer division.
[Answer]
# Bash + Coreutils, 60 47
```
date +%I\ 60*%M+45-30/24%%2~C*+16iF09F9590+P|dc
```
[Try it online!](https://tio.run/##S0oszvj/PyWxJFVBW9UzRsHMQEvVV9vEVNfYQN/IRFXVqM5ZS9vQLNPNwNLN0tTSQDugJiX5/38A "Bash ‚Äì Try It Online")
Emojis render fine on the OSX terminal, but for Linux (Ubuntu 14.04) you'll have to `sudo apt-get install ttf-ancient-fonts`
For testing different times, insert `-d $time` into the date command. e.g for testing 12:59:
```
date -d 12:59 +%I\ 60*%M+45-30/24%%2~C*+16iF09F9590+P|dc
```
[Answer]
# CJam, 31 bytes
```
"üïê")et5<60b675+30/24%2mdC*++
```
You can change the time in the following program to test it:
```
"üïê")[2014 12 19 22 14 1 901 5 -28800000]5<60b675+30/24%2mdC*++
```
[Answer]
# JavaScript ‚Äì ~~137~~ ~~117~~ ~~107~~ ~~102~~ 95 bytes
This is going to get easily beaten, but I'll just try my best here.
**EDIT 1**: Now prints in UTC like the Python answer to save 20 bytes.
**EDIT 2:** Changed `new Date().getTime()` to `Date.now()` to save 10 bytes.
**EDIT 3:** Changed `Math.round(x)` to `~~(x+.5)` to save 5 bytes.
**EDIT 4:** Removed unnecessary `(` and `&1023)` left from some old development version where I did a more universal UTF-16 encoding to save 7 bytes.
```
d=~~(Date.now()/18e5+.5)%24;d+=d<2?24:0;alert(String.fromCharCode(55357,56655+(d%2?23+d:d)/2));
```
JavaScript *does* allow for emojis, but in UTF-16 which encodes them as two characters. Luckily, we can simply define them as two characters; the first character is also constant (`0xD83D`), while the other changes.
**Alternative, prints in local time, ~~137~~ ~~132~~ 125:**
```
a=new Date();d=~~(a.getHours()%12*2+a.getMinutes()/30+.5);d+=d<2?24:0;alert(String.fromCharCode(55357,56655+(d%2?23+d:d)/2));
```
[Answer]
# CJam, 50 bytes
```
"üïê":i~et3=C%60*et4=+30d/mo2m24+24%_2%24*+2/+]:c
```
The algorithm is simple, round the time to nearest 30 minutes, count how many 30 minutes have passed since 12 AM/PM, if the number is odd, then add 24 to it, floor divide by 2 and increment the initial unicode by that many code points to get the right clock face.
Also, make sure that you start with 1 AM/PM instead of 12 so take an offset there.
For testing purposes, use the following code:
```
3:H;45:M;"üïê":i~HC%60*M+30d/mo2m48+48%_2%24*+2/+]:c
```
Where the `3:H;` part is the current hour and the `45:M;` part is the current minute of the hour. Simply replace `3` and `45` with the desired value.
[Try it online here](http://cjam.aditsu.net/)
*Not all unicode characters might print correctly on the online version depending upon your browser and OS and installed fonts. But for me, all print fine on Firefox with Windows 7.*
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 30 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
≈æa60*≈æb+45-30√∑24%2‚Ä∞`12*+≈Ω√º¬§¬∑+√ß
```
Port of [*@jimmy23013*'s CJam answer](https://codegolf.stackexchange.com/a/42528/52210), so make sure to upvote him as well!
[Try it online](https://tio.run/##yy9OTMpM/X90X9LRfYlKzqVFRal5JQolmbmpVgqH91sd3q@kw6UUlFpcmlNipQABSvZA5YlmBlpATdomprrGBoe3G5moGj1q2JBgaKSlfXTv4T2Hlhzarn14@X/7/wA) or [verify some manual test times](https://tio.run/##LcwxCsJAEIXhqywBG7PC7r7dGKscJARUsLCyEIR0Vh4gZxBsxSaNNgm2HiIXWcm8bf5hYOY7nXf74yFe2ipT061TWdXGwvxePqxgxt75hZuuz611y/z7Gd/Dfejz8RF1rGurTaNrJ4XUS4O0kK6lpXQjtYaD32khYjUogiRogiiogizogjCSjESD9jzUvPtSQBvk2oem@QM).
**Explanation:**
Uses the following formula to calculate the clock codepoint based on the given \$h\$ours and \$m\$inutes:
$$d(h,m) = \left\lfloor\frac{60h+m-45}{30}\right\rfloor\bmod{24} \\
C(h,m) = \left\lfloor\frac{d(h,m)}{2}\right\rfloor+12(d(h,m)\bmod{2})+128336$$
```
≈æa                              # Push the current hours
  60*                           # Multiply them by 60
     ≈æb+                        # Add the current minutes
        45-                     # Subtract 45
           30√∑                  # Integer-divided by 30
              24%               # Modulo 24
                 2‚Ä∞             # Divmod by 2: [n//2,n%2]
                   `            # Pop and push n//2 and n%2 separated to the stack
                    12*         # Multiply n%2 by 12
                       +        # Add it to the n//2
                        ≈Ω√º¬§     # Push compressed integer 64168
                           ¬∑    # Double it to 128336
                            +   # Add it as well
                             √ß  # Convert it to a character with this codepoint
                                # (after which the result is output implicitly)
```
[See this 05AB1E tip of mine (section *How to compress large integers?*)](https://codegolf.stackexchange.com/a/166851/52210) to understand why `≈Ω√º¬§` is `64168` (compressed `128336` directly is 1 byte longer: `‚Ä¢1√πŒ∏‚Ä¢`).
[Answer]
# [C (gcc)](https://gcc.gnu.org/) with `-m32`, ~~104~~ ~~100~~ 98 bytes
* -6 thanks to ceilingcat
```
*t;f(i){char a[]="üïê";time(&i);i=1[t=gmtime(&i)]/15;a[3]=144+(t[2]+11+i/4)%12+(i-1U<2)*12;puts(a);}
```
[Try it online!](https://tio.run/##TY1LCsIwGIT3niIEKkkf1KR1FeMtXIUuQjT1B1NLG92U3sGNa6/oCYxtQXA1fDPDjMlqY0KIvbAE6GDOukNaVRK/X88HFh7ciayBCpBMeVm7n1HlbCu0KirJyjIhXvEqYSyBvKQR4wmBjB12nMaMi/bme6KpGAM0HjkNDblf4UjRsEJotiCd7lczyGV@Q8UE/28zt93UtQRHPZJ7hFOke7Pkni65JZOM4WPsRdd9yFzBvw "C (gcc) ‚Äì Try It Online")
Ungolfed:
```
*t; // broken-down time structure ([1]=minutes, [2]=hours)
f(i){ // time
  char a[]="üïê"; // base emoji in modifiable UTF-8 string
  time(&i); // get time and convert into structure
  i=1[t=gmtime(&i)]/15; // get granular 15-minute chunks
  a[3]=
    144+ // base 4th byte of emoji
    (t[2]+11+i/4)%12+ // convert [0..23] to [1..24]-1 for hour, adding [0:45..1:00)
    (i-1U<2)*12; // add [0:15..0.45) as half-hour
  puts(a);
}
```
[Answer]
# [Go](https://go.dev), 265 bytes, function
```
import."time"
func f()rune{N,H:=Now(),Hour/2
e,l:=N.Truncate(H),N.Round(H)
if e.Sub(N).Abs()<l.Sub(N).Abs(){N=e}else{N=l}
return []rune("üïõüïßüïêüïúüïëüïùüïíüïûüïìüïüüïîüï†üïïüï°üïñüï¢üïóüï£üïòüï§üïôüï•üïöüï¶")[N.Hour()%12*2+N.Minute()/30]}
```
[Attempt This Online!](https://ato.pxeger.com/run?1=VdBNToQwGAbguLSnICSaVrGjuDFGFu7Y2Bh1N5kFg4UQoUygjQvCHfwb_0YdHB09g0fRU3gEX8SNiydf-7Vp872TWZw3H6MgPAliaWVBokiSjfJCW3aUaXtudLS29bWw2DW5rZNM2iQyKrQiygqjZCUcf9sT-Slljp-boucS6aTo8CMch4GW1GeO4Ae5UcdYkiSyJD80QyoY3x2WlO2k_7aV8GQt0xIve2lNCqlNoaz-oP2M2t_T8QTe4Qwe4Bwe4QKe4BKmcAUNjOEZrmEGN_ACt_AKdzCHe3izWV_wdg7KljbcFXdV8L1EGUzBepvrg7pL5HP5N4I2L8qsiiArvl8kStNSo8QU4TBG_m43TVd_AA)
Gets the current time, rounds up and down to the nearest half hour, finds the closer one, and returns the emoji that represents it.
# [Go](https://go.dev), 285 bytes, full program
```
package main
import."time"
func main(){N,H:=Now(),Hour/2
e,l:=N.Truncate(H),N.Round(H)
if e.Sub(N).Abs()<l.Sub(N).Abs(){N=e}else{N=l}
print(string([]rune("üïõüïßüïêüïúüïëüïùüïíüïûüïìüïüüïîüï†üïïüï°üïñüï¢üïóüï£üïòüï§üïôüï•üïöüï¶")[N.Hour()%12*2+N.Minute()/30]))}
```
[Attempt This Online!](https://ato.pxeger.com/run?1=VdA7TsNAEAZg0foOSJElpB0wGzANQqSgc8MWQBelcJK1tcLetexdUUS-A6_wSiAmJHAnTsER-HkVFJ92djQaaf7JPDVNs3Q22dx9X1kt4sFpnMpWHivtqbwwpeW-Vbn0vcTpwXef0UgE0V5HmDNGQWRc2Q49GWTo8JMSU7GVLKJA8CPj9BClp5KW5MeuzwTxg37FaD_79x2JjqxlVkkUWe0VpdKWVRZPyro97JTM_5iNJ_AG5zCFC3iES3iCK5jBNTQwhme4gTncwgvcwQLuYQkP8OpTV_CvaxitbYfr4Ybgh0o73ELtna0eUf2T0m9Yf6F9Ag)
[Answer]
# [Julia](https://julialang.org), 81 bytes
```
using Dates
n=now()
M=minute(n)
print('üïè'+mod1(hour(n)+(M>44),12)+12(14<M<45))
```
[Attempt This Online!](https://ato.pxeger.com/run?1=lVC9TsMwEN79FCcvuVNMVYdEQlHLxNAlA2o3xBC1LjFKzsixxWMwMTHQpU_ExFvwCJgUBCs33qfv9-V4H3vbHg7HGPZnF-_XcbR8B1dtMKPgJbtHJNEsB8sxGGQSD95ywOzj9fkpywe309i56BOSY3NZlqR0QbkuUJeLZlFWRN_CbxOxZ5SAm87ANnpvOECwg4HOeAN2BKlOzrO980MbcLJXcrWqm6ZeryUpkCRJiIQDg2XYJPoMcV4X55QpuJkrXamyuiUB6Xq3bXv4G__r--8Kv6wpf0qZlAzvTtV-tvsE)
Julia is generally picky with types, but some common arithmetic statements involving `Char`, `Int`, and `Bool` are permitted. The `Int` values of the clock emojis are the range `128336:128359`. The emojis are encoded in ascending order, with all the twelve that are on the hour coming before the twelve half-past emojis. In this algorithm, [the preceding character `'üïè'`](https://en.wikipedia.org/wiki/Bowl_of_Hygieia) is incremented by the 12-hour number (plus 1 if it's more than 44 minutes past the hour), and another 12 is added if the minute hand needs to be adjusted.
-17 bytes (!!) thanks to MarcMush: just use `Dates.minute` instead of parsing the time string
[Answer]
## Pascal, 134 characters
This `program` requires a processor supporting the time-related features defined by ISO standard 10206 ‚ÄúExtended Pascal‚Äù.
Furthermore the *implementation-defined* set of `char` values must include said Unicode characters.
```
program t(output);var t:timeStamp;begin getTimeStamp(t);write(('üïõüïßüïêüïúüïëüïùüïíüïûüïìüïüüïîüï†üïïüï°üïñüï¢üïóüï£üïòüï§üïôüï•üïöüï¶')[t.hour mod 12*2+round(t.minute/30)+1])end.
```
Ungolfed:
```
program clock(output);
    var
        ts: timeStamp;
    begin
        getTimeStamp(ts);
        { This `program` presumes `ts.timeValid` is set to `true`. 
          Otherwise `getTimeStamp` sets the clock to midnight. Insert
          
            ts.hour := 11;
            ts.minute := 48;
        
          here to test the functionality of this `program`. }
        writeLn(('üïõüïßüïêüïúüïëüïùüïíüïûüïìüïüüïîüï†üïïüï°üïñüï¢üïóüï£üïòüï§üïôüï•üïöüï¶')
            [ts.hour mod 12 * 2 + round(ts.minute / 30) + 1]);
    end.
```
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 98 bytes
```
Print@FromCharacterCode[128336+Quotient[#,2]+12Mod[#,2]&[Mod[Quotient[UnixTime[]-2700,900]/2,24]]]
```
Original Code is
```
a = Mod[Quotient[UnixTime[] - 3 * 900, 900] / 2, 24];
result = FromCharacterCode[128336 + Quotient[a, 2] + Mod[a, 2] * 12];
Print[result]
```
]