This might be shorter:

   F=:86400%~24 60 60#.]
   T=:F inv ::([:F 2 5}~&' ')

   T'12:00:00'
0.5
   T 0.5
12 0 0
   T '12:00:00'
0.5
   T 0.5
12 0 0
   T '12:34:56'
0.524259
   T 0.524259
12 34 55.9776

I hope this helps,

-- 
Raul


On Mon, Mar 13, 2017 at 12:45 PM, Richard Donovan <[email protected]> wrote:
> Just discovered CodeGolf, where you have to program a solution to a problem 
> in the language of your choosing, and the answer with the least characters 
> wins!
>
> I tried this problem 
> http://codegolf.stackexchange.com/questions/52830/decimal-time-of-day-conversion/106069#106069
>  and my answer (below), at 85 bytes is currently third place!
>
> Can anyone do better!
>
> Cheers,
>
> Richard Donovan
>
>
> J, 85 bytes
>
> Results:
>
> T '12:00:00'
> 0.5
>
> T 0.5
> 12 0 0
>
> T '12:34:56'
> 0.524259
>
> T 0.524259
> 12 34 56
>
> T=:3 :'a=.86400 if.1=#y do.>.(24 60 60#:y*a)else.a%~+/3600 60 1*".y#~#:192 24 
> 3 end.'
>
>
> Total 85
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to