{ # calculate hour, minute, and seconds, and days since 1970/1/1 s = $1 % 60; t = int($1/60); m = t % 60; t = int( t/60); h = t % 24; days_from_epoch = int( t/24); # calculate year max_calced_year = 1970; # To remember every days on 01/01 from days_on_Jan1st_from_epoch[1970] = 0; # the Epoch which was calculated once Y = int(days_from_epoch/365.2425)+1970+1; if (Y > max_calced_year) { i = days_on_Jan1st_from_epoch[max_calced_year]; for (j=max_calced_year; j= days_on_Jan1st_from_epoch[Y]) { break; } } # calculate month and date split("31 0 31 30 31 30 31 31 30 31 30 31", days_of_month); # not sure for February yet days_of_month[2] = (Y%4!=0)?28:(Y%100!=0)?29:(Y%400!=0)?28:29; D = days_from_epoch - days_on_Jan1st_from_epoch[Y] + 1; for (M=1; ; M++) { if (D > days_of_month[M]) { D -= days_of_month[M]; } else { break; } } # finally printf("%04d/%02d/%02d %02d:%02d:%02d\n",Y,M,D,h,m,s); }