How to get seconds since unix in Hell?

I feel really stupid, because I don’t seem to get the usual natural number representing the seconds since unix (01/01/1970 00:00:00) in Hell. I read Ada.Calendarit and it subpackages up and down, but it seems that I have not found a reasonable way to achieve this, although it Ada.Calendar.Clockshould be exactly what I want ...

I am on my way. Any push in the right direction?

+4
source share
3 answers

Using Ada.Calendar.Formatting, build Timerepresenting an era .

Epoch : constant Time := Formatting.Time_Of(1970, 1, 1, 0.0);

Learn the difference between Ada.Calendar.Clockand Epoch.

Put(Natural(Clock - Epoch)'Img);

epoch display Unix date +%s.

. Ada 2005: §7.3 .

+6

POSIX UNIX time , Ada.Calendar. "-" :

, Days = 0, Seconds + Duration (Leap_Seconds) = . "-" (, ).

- Ada.Calendar.Time , Ada.Calendar.Formatting.Split POSIX.

Ada.Calendar.Arithmetic.Difference, , Leap_Seconds. Days * 86_400 + Seconds UNIX, Leap_Seconds POSIX.

+1

There is also the Ada.Calendar.Conversions package, which links ada ↔ unix conversions.

0
source

Source: https://habr.com/ru/post/1619621/


All Articles