Date: Tue, 21 May 2002 13:05:35 +0300 (IDT) From: Eli Zaretskii X-Sender: eliz AT is To: Alex Vinokur cc: djgpp AT delorie DOT com Subject: Re: mktime() & time_t In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Tue, 21 May 2002, Alex Vinokur wrote: > | > However : May mktime() return -1 ? > | > | It's in the docs: mktime returns -1 if you feed it with time outside the > | range of dates it can represent. > > But in this case mktime() returns UINT_MAX ( not -1 ) because time_t if of 'unsigned int' type. The bit patterns of UINT_MAX and -1 are exactly the same in DJGPP, so these are just two different names for the same value. The reason the docs doesn't say UINT_MAX is that time_t can be signed on some platforms, unsigned on others. Using -1 for comparison makes your programs more portable. Especially since the C standard and Posix both say mktime should return -1 if it fails. The same situation occurs with functions like `read' and `write', IIRC.