/
niceSOFT
/
gawk
Обзор
Документация
Войти
/
niceSOFT
/
gawk
Код
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
test/time.awk
28 строк
765 B
Arnold D. Robbins
Undeprecate the time extension, add strptime, update tests and doc.
22 янв 2023, 22:58
22 янв 2023, 22:58
6e195e4
Код
Авторство
О чём код?
@load "time" # make sure gettimeofday() is consistent with systime(). We must call # gettimeofday() before systime() to make sure the subtraction gives 0 # without risk of rolling over to the next second. function timecheck(st,res) { res = gettimeofday() st = systime() printf "gettimeofday - systime = %d\n", res-st return res } BEGIN { delta = 1.3 t0 = timecheck() printf "sleep(%s) = %s\n",delta,sleep(delta) t1 = timecheck() slept = t1-t0 if ((slept < 0.9*delta) || (slept > 1.3*delta)) printf "Warning: tried to sleep %.2f secs, but slept for %.2f secs\n", delta,slept format = "%b %d %H:%M:%S %Y" the_date = "Feb 11 13:12:11 1990" then = strptime(the_date, format) when = strftime(format, then) print "<" the_date ">", "<<" when ">>" }