0

I recently encountered a code that read

time_t zombieDate(0x510B56CB);

1) I know that time_t is a arithmetic variable type but what is its limit?

2) zombieDate is the name given to the variable but is the code above equivalent to:

time_t zombieDate = 0x510B56CB 

Thanks!

Jason Lee
  • 15
  • 1
  • 5
  • 1
    `time_t` is implementation defined, but it must be able to hold at least the number of seconds since Jan 1, 1970. Look for the typedef in your system headers. It may be in ctime or another header ctime includes. – Retired Ninja Dec 06 '14 at 09:50
  • 1
    possible duplicate of [What is ultimately a time\_t typedef to?](http://stackoverflow.com/questions/471248/what-is-ultimately-a-time-t-typedef-to) – Retired Ninja Dec 06 '14 at 09:51
  • When I search online, I got "Time type: Alias of a fundamental arithmetic type capable of representing times, as those returned by function time." But I couldn't see how I should use it. – Jason Lee Dec 06 '14 at 09:56
  • On my computer, it says: typedef __time64_t time_t; and typedef __int64 __time64_t; – Jason Lee Dec 06 '14 at 09:59
  • @Retired Ninja Sry, I still do not understand how the value is passed in. – Jason Lee Dec 06 '14 at 10:39
  • 1
    Passed into what? Both of those lines assign 0x510B56CB to a time_t variable named zombieDate. http://en.wikipedia.org/wiki/Initialization_%28programming%29 – Retired Ninja Dec 06 '14 at 10:43

1 Answers1

0

I know that time_t is a arithmetic variable type but what is its limit?

It's implementation dependent. On POSIX systems, it must be at least 32 bits, to cover times up to at least the year 2038. You can get the limit for your implementation as you can for any numeric type:

std::numeric_limits<time_t>::max

is the code above equivalent to...

Yes, if you add the missing ; to the second declaration. For numeric types copy-initialisation and direct-initialisation both do the same thing.

Mike Seymour
  • 249,747
  • 28
  • 448
  • 644