DATE_TIME 对象自埃菲尔纪元以来的秒数

number of seconds since epoch in eiffel for a DATE_TIME object

你如何计算 DATE_TIME 对象自埃菲尔纪元以来的秒数?

使用当前库的正确方法是什么?

你可以像这样计算自纪元以来的秒数

number_of_seconds_since_epoch
        -- calculate the number of seconds since epoch in eiffel
    local
        l_date_epoch: DATE_TIME
        l_date_now: DATE_TIME
        l_diff: INTEGER_64
    do
        create l_date_epoch.make_from_epoch (0)
        create l_date_now.make_now_utc
        l_diff := l_date_now.definite_duration (l_date_epoch).seconds_count
        print ("%NEpoch:" + l_date_epoch.out)
        print ("%NNow:" + l_date_now.out)
        print ("%NDiff in seconds:" + l_diff.out)
    end