define ["./dom", "./moment"],
(dom, moment) ->
ATTR = "data-timeinterval"
DEFAULT_FORMAT = 'YYYY-MM-DDTHH:mm:ss.SSSZ'
toMoment = (s) -> if s then (moment s, DEFAULT_FORMAT) else moment()
updateElement = (el) ->
start = toMoment el.attr "data-timeinterval-start"
end = toMoment el.attr "data-timeinterval-end"
plain = el.attr "data-timeinterval-plain"
el.update end.from start, plain
return
updateDynamics = ->
for el in dom.body.find "[#{ATTR}=dynamic]"
updateElement el
return