ctime64_r, localtime64_r, gmtime64_r, or asctime64_r Subroutine

Purpose

Converts the formats of date and time representations.

Library

Thread-Safe C Library (libc_r.a)

Syntax

#include <time.h>


char *ctime64_r(Timer, BufferPointer)
const time64_t * Timer;
char * BufferPointer;

struct tm *localtime64_r(Timer, CurrentTime)
const time64_t * Timer;
struct tm * CurrentTime;

struct tm *gmtime64_r (Timer, XTime)
const time64_t * Timer;
struct tm * XTime;

char *asctime64_r (TimePointer, BufferPointer)
const struct tm * TimePointer;
char * BufferPointer;

Description

The ctime64_r subroutine converts a time value pointed to by the Timer parameter, which represents the time in seconds since 00:00:00 Coordinated Universal Time (UTC), January 1, 1970, into the character array pointed to by the BufferPointer parameter. The character array should have a length of at least 26 characters so the converted time value fits without truncation. The converted time value string takes the form of the following example:

Sun Sept 16 01:03:52 1973\n\0

The width of each field is always the same as shown here. Thus, ctime will only return dates up to December 31, 9999.

The ctime64_r subroutine adjusts for the time zone and daylight saving time, if it is in effect.

The localtime64_r subroutine converts the time64_t structure pointed to by the Timer parameter, which contains the time in seconds since 00:00:00 UTC, January 1, 1970, into the tm structure pointed to by the CurrentTime parameter. The localtime64_r subroutine adjusts for the time zone and for daylight saving time, if it is in effect.

The gmtime64_r subroutine converts the time64_t structure pointed to by the Timer parameter into the tm structure pointed to by the XTime parameter.

The tm structure is defined in the time.h header file. The time.h file contains declarations of these subroutines, externals, and the tm structure.

The asctime64_r subroutine converts the tm structure pointed to by the TimePointer parameter into a 26-character string in the same format as the ctime64_r subroutine. The results are placed into the character array, BufferPointer. The BufferPointer parameter points to the resulting character array, which takes the form of the following example:

Sun Sept 16 01:03:52 1973\n\0

Programs using this subroutine must link to the libpthreads.a library.

Parameters

Item Description
Timer Points to a time64_t structure, which contains the number of seconds since 00:00:00 UTC, January 1, 1970.
BufferPointer Points to a character array at least 26 characters long.
CurrentTime Points to a tm structure. The result of the localtime64_r subroutine is placed here.
XTime Points to a tm structure used for the results of the gmtime64_r subroutine.
TimePointer Points to a tm structure used as input to the asctime64_r subroutine.

Return Values

The localtime64_r and gmtime64_r subroutines return a pointer to the tm structure. The asctime64_r returns NULL if either TimePointer or BufferPointer is NULL.

The ctime64_r and asctime64_r subroutines return a pointer to a 26-character string. The ctime64_r subroutine returns NULL if the BufferPointer is NULL.

The difftime64 subroutine returns the difference expressed in seconds as a value of type long double.

Files

Item Description
/usr/include/time.h Defines time macros, data types, and structures.