What's the Binary Time?
CJam, 20 bytes
l':/60b9m<675/2bG0e[
Test suite.
Explanation
Makes use of the fact that 65536 (216) over 86400 (the number of seconds in a day) simplifies to 512 over 675.
l e# Read input.
':/ e# Split around ':', so we get ["hh" "mm" "ss"].
60b e# Interpret as base-60 digits, which computes hh*60^2 + mm*60 + ss,
e# i.e. it computes the total number of seconds. Note that this implicitly
e# converts all three strings to integers.
9m< e# Bitwise left-shift by 9 positions, which is the same as multiplying by
e# 2^9 = 512.
675/ e# Divide by 675, flooring the result.
2b e# Convert to binary.
G0e[ e# Left-pad with zeros to 16 digits.
Pyth, 31 27 bytes
.[\016.Bs*512cisMcQ\:60 675
Test suite.
Converts the input into number of seconds passed, multiply by a factor of 2^16 / 24*60*60
, and then floor and convert to 16-bit binary.
Saved 4 bytes by simplifying 65536/86400
into 512/675
(stupid me).
Input/output
00:00:00 0000000000000000
11:00:00 0111010101010101
12:00:00 1000000000000000
01:30:00 0001000000000000
10:33:06 0111000010001101
09:57:30 0110101000111000
06:00:00 0100000000000000
18:00:00 1100000000000000
23:59:59 1111111111111111
TSQL(sqlserver 2012), 103 bytes
DECLARE @d datetime = '10:33:06'
DECLARE @ char(16)='',@x INT=cast(@d as real)*131072WHILE
len(@)<16SELECT @x/=2,@=concat(@x%2,@)PRINT @
Try it online
Ungolfed
DECLARE @d datetime = '10:33:06'
DECLARE @ char(16)='',
@x INT=cast(@d as real)*131072
WHILE len(@)<16
SELECT @x/=2,@=concat(@x%2,@)
PRINT @
TSQL(sqlserver 2012), 119 106 bytes
Also included a different version without the variable @x, however it was a few bytes longer. Including the ungolfed version for those interested:
DECLARE @d datetime = '23:59:59'
DECLARE @ varchar(16) =''
WHILE LEN(@)<16
SET @+=LEFT(CAST(@d as decimal(9,9))*2*POWER(2,LEN(@))%2,1)
PRINT @