Portál AbcLinuxu, 1. června 2025 04:24
man clock_gettime
:
All implementations support the system-wide real-time clock, which is identified by CLOCK_REALTIME. Its time represents seconds and nanoseconds since the Epoch. When its time is changed, timers for a relative interval are unaffected, but timers for an absolute point in time are affected.
Ovšem nerozumím tomu, co se myslí tím "absolute point in time". Všechny časy jsou přece relativní.
Řešení dotazu:
$ date -u 10300059.45
pro tento cas vrati clock_gettime(CLOCK_REALTIME, &time)
hodnotu 1319936385
po 30 sekundach se cas zmeni na 01:00.15 UTC coz je 02:00.15 stredoevropskeho zimniho casu. (= 15 sec po zmene)
v tuto chvili clock_gettime(CLOCK_REALTIME, &time)
vraci 1319936415
Rozdil je 30 sec, tedy skutecny cas, ktery uplyne.
Zaver: Pri zmene casu nedochazi ke zmene casu systemu, jenom se zmeni prepocet na lokalni cas. V souboru tak zadny skok o jednu hodinu zpet nebude.
CLOCK_REALTIME. Its time represents seconds and nanoseconds since the Epoch.Je to tedy počet sekund od někdy, nikoli lidský čas.
Tiskni
Sdílej:
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.