Skip to content
Robert Gersak edited this page Jan 14, 2019 · 9 revisions

Once upon a time

There was a second. Second was pretty and well known throughout the world and everybody liked second. It had many cousins like minute, and hour and even small cousins like millisecond. It was the most beautiful unit of all time units. (I’m having so much fun writing this) Then Mr. Computer Programmer Engineer came and said:

"Hey! Let’s think about this. We don’t want to be week on seconds charms and we should think this throughout. One day millisecond will be a second or maybe even a minute but second can never be a millisecond. Not as whole at least. I say that millisecond is more beautiful than second is"

— Mr. Computer Programmer Engineer

 
Everybody knew that Mr. Computer Programmer Engineer was right to say so and it was wrong to split pretty seconds( as well as number math is so much easier when you don’t have to split your fingers). In the end millisecond is just as beautiful as second is. It is just that "everybody" wasn’t used to it. But they will be…​ At least until Mr. Future Computer Programmer Engineer arrives with pretty nanosecond idea.

Value doesn’t matter!

How can you say that? Vura is all about time and value and stuff…​

Look:
;; Everybody loves second
(def second 1)
(def millisecond (/ second 1000))
(def microsecond (/ millisecond 1000))
(def nanosecond (/ microsecond 1000))
(def minute 60)
(def hour (* 60 minute))
(def day (* 24 hour))
(def week (* 7 day))

;; Everybody loves millisecond
(def millisecond 1)
(def second (* millisecond 1000)
(def microsecond (/ millisecond 1000))
(def nanosecond (/ microsecond 1000))
(def minute 60)
(def hour (* 60 minute))
(def day (* 24 hour))
(def week (* 7 day))

;; Everybody loves nanosecond
(def nanosecond 1)
(def microsecond (* nanosecond 1000))
(def millisecond (* 1000 microsecond))
(def second (* millisecond 1000)
(def minute 60)
(def hour (* 60 minute))
(def day (* 24 hour))
(def week (* 7 day))

 
Did something change? Sure, finger math size changed. Ratios/relations are still the same only base of computation is different. But it doesn’t matter if we are operating with +, -, /, *, or round-number on defined values we are still a OK. Point is this approach doesn’t break the code if we change base unit. It shouldn’t. We are operating on value whatever that value is.

Date is the Gate

To the value domain. If we say that we wan’t to work with Date as numeric value than this is only point of implementation( except above) that does matter. How to transform Date → value( second, millisecond, nanosecond) and how to transform back when computation is over from value → Date.

Clone this wiki locally