Displaying 2 results from an estimated 2 matches for "date_span".
2014 Dec 15
2
Replace atoi and atol with strtol strtoul:Need Help
Hello,
I am working on replacing atoi () and atol() functions with strtol() and
strtoul() . I came across many files which uses statement like these
time_t secs= atoi(data_span.c_str()), here time_t Datatype is not known but
wikipedia says that it is integer so is it necessary to replace atoi with
strtol over here ??
And is their any document which helps me what each file function does like
2014 Dec 16
2
Replace atoi and atol with strtol strtoul:Need Help
...to be a
> signed integer, and it is 64 bit on modern systems (since a signed 32
> bit integer with the Unix epoch can only represent dates up to 2038).
>
> You missed out a relevant part of line, which in full is:
>
> xapian-applications/omega/date.cc: time_t secs =
> atoi(date_span.c_str()) * (24 * 60 * 60);
>
> So in this case, date_span is a number of days, so converting it via a
> long is reasonable - even if long is 32 bits that can still represent a
> span of 5.8 million years. You'd want to make sure the multiplication
> happens in type time_t though...