32 bit time stamp to date and time
Hi, I am writing a simple NTP client. NTP retuns the time as a 32bit value, as the seconds since 1900. using boost date time library is it possible to convert it to a date and time (year,month,day of week,day,hour,minute,second) ? Thanks, Lloyd ______________________________________ Scanned and protected by Email scanner
On Sun, 2010-10-24 at 08:32 +0300, Lloyd wrote:
I am writing a simple NTP client. NTP retuns the time as a 32bit value, as the seconds since 1900. using boost date time library is it possible to convert it to a date and time (year,month,day of week,day,hour,minute,second) ?
from_time_t minus the seconds between 1900-1970. --> Mika
Sorry, I did not understand. My doubt is
if the 32bit input value is 70 (70 seconds since 1900), the output would be
1900-01-01, 00:01:10., and the day of week is Monday
By using the function "from_time_t " can we get this output?
Thanks,
Lloyd
----- Original Message -----
From: "Mika Heiskanen"
On Sun, 2010-10-24 at 08:32 +0300, Lloyd wrote:
I am writing a simple NTP client. NTP retuns the time as a 32bit value, as the seconds since 1900. using boost date time library is it possible to convert it to a date and time (year,month,day of week,day,hour,minute,second) ?
from_time_t minus the seconds between 1900-1970.
--> Mika
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
______________________________________ Scanned and protected by Email scanner
Sorry, I did not understand. My doubt is
if the 32bit input value is 70 (70 seconds since 1900), the output would be 1900-01-01, 00:01:10., and the day of week is Monday
By using the function "from_time_t " can we get this output?
time_t is number of seconds since 1/11970 If your input is the number of seconds since 1/1/1900, then before using from_time_t() you have to add the number of seconds between 1/1/1900 and 1/1/1970. IIRC, it's (70 * 365 + 17) * 86400
Thanks a lot. Now I understood it. Is it possible to get day of week (Sunday, monday,...saturday) from ptime? Thanks again, Lloyd
time_t is number of seconds since 1/11970 If your input is the number of seconds since 1/1/1900, then before using from_time_t() you have to add the number of seconds between 1/1/1900 and 1/1/1970. IIRC, it's (70 * 365 + 17) * 86400 _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
______________________________________ Scanned and protected by Email scanner
----- Original message -----
Is it possible to get day of week (Sunday, monday,...saturday) from ptime?
You can get the date from ptime via .date() and there's a .day_of_week() function for that. (I don't have a doc at hand right now, so the exact naming might be slightly different.) hth, Norbert
Thanks a lot. Now I understood it. Is it possible to get day of week (Sunday, monday,...saturday) from ptime?
Please take a look into ptime reference: http://www.boost.org/doc/libs/1_44_0/doc/html/date_time/posix_time.html#date...
Thanks Mika, Norbert and Igor. I had gone through the documentation, but the
way I searched lead me to nothing. Thanks for showing it. Now it works.
Thanks again,
Lloyd
----- Original Message -----
From: "Igor R"
Thanks a lot. Now I understood it.> Is it possible to get day of week (Sunday, monday,...saturday) from ptime? Please take a look into ptime reference:http://www.boost.org/doc/libs/1_44_0/doc/html/date_time/posix_time.html#date... mailing listBoost-users@lists.boost.orghttp://lists.boost.org/mailman/listinfo.cgi/boost-users
______________________________________ Scanned and protected by Email scanner
participants (4)
-
Igor R
-
Lloyd
-
Mika Heiskanen
-
Norbert Wenzel