acme
Foundational cross-platform layer of the ca2 framework
Loading...
Searching...
No Matches
dos_time1.h File Reference

Definitions for the MS-DOS to Unix time conversions. More...

#include <time.h>
#include <inttypes.h>

Go to the source code of this file.

Typedefs

typedef uint32_t dostime_t

Functions

CLASS_DECL_ACME dostime_t minimum_dos_time ()
 Return the minimum possible value.
CLASS_DECL_ACME dostime_t maximum_dos_time ()
 Return the maximum possible value .
CLASS_DECL_ACME posix_time dos_time_unix_time (dostime_t dostime)
 Convert a DOS time to a Unix time.
CLASS_DECL_ACME dostime_t dos_time (::i32 year, ::i32 month, ::i32 day, ::i32 hour, ::i32 minute, ::i32 second)
CLASS_DECL_ACME dostime_t unix_time_dos_time (posix_time unix_time)
 Convert a Unix date to a DOS date.

Detailed Description

Definitions for the MS-DOS to Unix time conversions.

This header defines a few functions helping in converting MS-DOS to Unix time and vice versa.

Note
This uses C code.

Function Documentation

◆ dos_time_unix_time()

CLASS_DECL_ACME posix_time dos_time_unix_time ( dos_time_t dostime)

Convert a DOS time to a Unix time.

This function returns the Unix posix_time value (GMT/UTC time) from the DOS format (local) time dostime, where dostime is a four ::u8 value (date in most significant word, time in least significant word), see dostime() function.

If the input DOS time is invalid, then the function returns -1.

Note
If the dostime is not valid (one of the parameters is out of range) then the function returns -1.
Parameters
[in]dostimeA DOS time value as found in a zip file.
Returns
The DOS time converted to a Unix time or -1.
See also
dostime()

\FIXME Maximum for tm_mday depends on month/year.

◆ maximum_dos_time()

CLASS_DECL_ACME dostime_t maximum_dos_time ( )

Return the maximum possible value .

This function returns the maximum DOS time that can be represented in a dos_time_t parameter.

At this time we use a 32 bit field (like the Zip archive) so the maximum is Dec 31, 2107 23:59:59.

Note
To get the corresponding Unix time, use the dos2unixtime() as in:
posix_time max(dos2unixtime(maxdostime()));
Definition posix_time.h:8
Returns
The largest possible DOS time.

◆ minimum_dos_time()

CLASS_DECL_ACME dostime_t minimum_dos_time ( )

Return the minimum possible value.

This function returns the minimum DOS time that can be represented in a dos_time_t parameter.

At this time we use a 32 bit field (like the Zip archive) so the maximum is Dec 31, 2107 23:59:59.

Note
To get the corresponding Unix time, use the dos2unixtime() as in:
posix_time min(dos2unixtime(mindostime()));
Returns
The smallest possible DOS time.

◆ unix_time_dos_time()

CLASS_DECL_ACME dostime_t unix_time_dos_time ( posix_time unix_time)

Convert a Unix date to a DOS date.

This function return the Unix posix_time converted in DOS format, rounded up to the next even second.

Parameters
[in]unix_timeA Unix posix_time value.
Returns
The Unix date in DOS format unless it is out of range for a DOS time and date in which case zero (0) is returned.