how would you calculate the number of seconds since epoch in eiffel for a DATE_TIME object?
Assuming variable t
is of type DATE_TIME
(in UTC), the code to get the corresponding number of seconds since the epoch is
t.definite_duration (create {DATE_TIME}.make_from_epoch (0)).seconds_count
Note. If the calculation is performed rather often, it might be more efficient to create an object epoch
of type DATE_TIME
with create epoch.make_from_epoch (0)
in advance and to use it in the calculation instead:
t.definite_duration (epoch).seconds_count