# A decimal-based unit of time

### Background

In 1960, the 11th General Conference on Weights and Measures defined the Système International d'Unités (SI) Units which scientists still use today.

The metre and the kilogram became standard units in that conference. These were based on powers of 10 (10, 100, 1000, etc.).

For example:

• there are 100 centimetres in one meter
• there are 1000 meters in one kilometer
• there are 1000 grams in one kilogram

### Time units

That conference also established the second as the standard unit for time. Now, this is interesting, because this is not based on powers of 10.

• There are 60 seconds in one minute
• There are 60 minutes in one hour
• There are 24 hours in one day

So let's make our own!

In our system, we will have:

• 100 seconds in one minute
• 100 minutes in one hour
• 10 hours in one day

Given an input of a time (in 24-hour time), convert it to our system (10-hour).

Example:

Input: 12:34:56

First, convert this to a number of seconds:

(12 * 60 * 60) + (34 * 60) + 56 = 45296

We have 100,000 seconds in our system, and in the normal system there are 86,400. We need to adjust for that:

45296 / 86400 * 100000 = 52425.9259259259

We round this to 52426. Note: this must be rounded.

Now, convert back to hours, minutes and seconds. This is easy because our 10-100-100 system lets us just place the colons in: 5:24:26. This is our final answer.

Note: you do not need to insert the colons.

### Test cases

You can input and output in any format you want, including just an integer as the output format.

Here are some test cases:

Input     Output
12:34:56  5:24:26
00:00:00  0:00:00*
23:59:59  9:99:99
11:11:11  4:66:10
15:25:35  6:42:77
01:02:03  0:43:09*


* In these ones, you do not have to fill the minutes and seconds up to two places: i.e., you may output 0:0:0 and 0:43:9.

This is , so shortest answer in bytes wins!

• Sandbox Oct 10, 2022 at 16:49
• Historical aside: this decimal time system was officially adopted in France for part of 1794 and 1795. Oct 10, 2022 at 22:54
• Related Oct 11, 2022 at 18:16
• In other words, Implement Swatch Internet Time to 1/100th of a Beat. Oct 12, 2022 at 11:31

# JavaScript (ES6), 33 bytes

Expects (h,m,s) and returns an integer.

(h,m,s)=>(h*60+m+s/60)*625/9+.5|0


Try it online!

### How?

By converting to minutes instead of seconds, the final ratio is:

$$\frac{60\times 100000}{86400}=\frac{625}{9}$$

This is one byte shorter than:

(h,m,s)=>(h*3600+m*60+s)/.864+.5|0


# 05AB1E, 10 9 bytes

No 05AB1E yet? Let's fix that!

This is a direct port of hakr14's canvas answer.

60βƵOƵ7/*ò


Try it online!

60βƵOƵ7/*ò
60β           Convert input from base 60
ƵOƵ7/      Push 125/108
*     Multiply input and 125/108
ò    Round


Thanks to @TheThonnu for this answer:

60β.864/ò


Try it online!

60β.864/ò
60β          Convert input from base 60
.864      Push .864 (108/125)
/     Divide input by 108/125
ò    Round

• 9 bytes Jan 14 at 10:36
• @TheThonnu So simple, why didn't i think of that? Nicely done, thanks! Jan 16 at 12:43

# Python, 39 bytes

Port of @Arnauld's answer, expects an input of h, m, s and returns an integer.

lambda h,m,s:round((h*60+m+s/60)*625/9)


Attempt This Online!

# Factor, 35 bytes

[ 60 * rot 60 / + + 625/9 * round ]


Try it online!

Expects seconds minutes hours as integers. Port of Arnauld's JavaScript answer.

      ! 56 34 12
60    ! 56 34 12 60
*     ! 56 34 720
rot   ! 34 720 56
60    ! 34 720 56 60
/     ! 34 720 14/15
+     ! 34 720+14/15
+     ! 754+14/15
625/9 ! 754+14/15 69+4/9
*     ! 52425+25/27
round ! 52426


# Jelly, 11 bytes

ḅ60÷.864+.Ḟ


A monadic Link that accepts a list of non-negative integers, [h, m, s], and yields a non-negative integer.

Try it online! Or see the test-suite.

### How?

ḅ60÷.864+.Ḟ - Link: list of non-negative integers, T = [h, m, s]:
ḅ60         - convert T from base sixty -> 3600*h+60*m+s = seconds
.864    - 0.864 (seconds per "second")
÷        - (seconds) divide (0.864) -> "deconds"
.  - a half
+   - (deconds) add (a half)
Ḟ - floor to nearest integer

• You need to add .432 before dividing to round correctly (.5 only works after you divide).
– Neil
Oct 10, 2022 at 19:58
• Oops, that was dumb! Thanks @Neil Oct 10, 2022 at 22:33

# Python 3, 65 bytes

h,m,s=map(int,input().split())
print(round((h*3600+m*60+s)/.864))


Takes input as HH mm ss and outputs as Hmmss

-3 thanks to Jonathan Allan

Try it online!

• /.864 saves three bytes. Oct 10, 2022 at 17:17

# C (GCC), 73 68 bytes

-5 bytes thanks to @Neil

f(char*x){return((atoi(x)*3600+atoi(x+3)*60+atoi(x+6))*125+54)/108;}


Attempt This Online!

• 41 bytes
– jdt
Oct 11, 2022 at 18:08
• or 36 bytes based on Arnauld's
– jdt
Oct 11, 2022 at 18:18
• @jdt you can post it as a new answer if you want, it's basically a new solution (although ported from another language) Oct 14, 2022 at 13:32

# Charcoal, 13 bytes

Ｉ⌊⊘⊕∕↨⁶⁰Ａ·⁴³²


Try it online! Link is to verbose version of code. Takes input as a list. Explanation:

       Ａ        Input array
↨          Converted from base
⁶⁰        Literal integer 60
∕           Divided by
·⁴³²   Literal number 0.432
⊕            Incremented
⊘             Halved
⌊              Floor
Ｉ               Cast to string
Implicitly print


26 bytes for string I/O:

✂⪫⪪﹪%06.0f∕↨⁶⁰Ｉ⪪Ｓ:·⁸⁶⁴¦²:¹


Try it online! Link is to verbose version of code.

# Canvas, 13 bytes

‾-┴‾n‾]÷×１½＋ｕ


Try it here!

##### Explanation:
‾-┴‾n‾]÷×1½+u | Full code (converted to half-width)
--------------+------------------------------------
‾-┴           | Convert input from base 60
‾n‾]÷      | Push 125/108
×     | Multiply
u | Floor


# J, 19 bytes

0.864<.@%~0.5+60#.]


Try it online!

# Japt, 11 bytes

ì60 /.864 r


Try it

# Pyth, 12 bytes

/hyiQ60y.864


Try it online! Input takes a list [hours, minutes, seconds], and outputs an integer.

Explanation:

/hyiQ60y.864 # whole program

Q        # take the input
i 60      # and convert it from base 60 to decimal
y          # double it
h           # increment it
/            # then integer divide it by
y.864 # 0.864 doubled (which is 1.728)


# Retina 0.8.2, 40 bytes

\d+
$* +1: :60$*
1
125$* :: 54$*
1{108}


Try it online! Link includes test cases. Explanation: Port of my golf to @matteo_c's answer.

\d+
$*  Convert the hours, minutes and seconds to unary. +1: :60$*


Convert from base 60, by multiplying each 1 by 60 as it passes a : on its way to being a number of seconds.

1
125$*  Multiply by 125. :: 54$*


1{108}


Integer divide by 108 and convert to decimal.

# MathGolf, 15 bytes

╚*j╟*++╔/☼*∞)i½


Inputs as three loose floats, output as a single integer.

Try it online.

Explanation:

Even though MathGolf has single-byte constants for 60, 3600, 86400, and 100000, it's still pretty long because it's missing base-conversion and round builtins, so those have to be done by manually.

╚*               # Multiply the first (implicit) input by 3600
j              # Get the second input-float
╟*            # Multiply it by 60
+           # Add the two together
+          # Also add the third (implicit) input-float
╔/        # Divide this by 86400
☼*      # Multiply it by 100000
∞)i½  # Round it:
∞     #  Double this float
)    #  Increase it by 1
i   #  Truncate it to an integer
½  #  Integer-divide it by 2
# (after which the entire stack is output implicitly as result)


# Thunno, $$\ 11 \log_{256}(96) \approx \$$ 9.05 bytes

aKAd.864/Zv


#### Explanation

aKAd.864/Zv  # Implicit input
aKAd         # Convert from a list of digits in base-60
.864/    # Divide by .864
Zv  # Round to the nearest integer
# Implicit output