[Previous]
[Contents]
[Next]

_ctime()

convert calendar time to local time

Synopsis:

#include <time.h>
char *_ctime( const time_t *timer, char *buf );

Description:

The _ctime() function converts the calendar time pointed to by timer to local time, in the form of a string containing exactly 26 characters. This string has the form shown in the following example:

Sat Mar 21 15:58:27 1987\n\0

All fields have a constant width. The newline character '\n' and the null character '\0' occupy the last two positions of the string.

The ANSI function ctime() places the result string in a static buffer that is reused each time ctime() or asctime() is called. The non-ANSI function _ctime() places the resulting string in the buffer pointed to by buf.

Whenever the _ctime() function is called, the tzset() function is also called.

The calendar time is usually obtained by using the time() function. That time is Coordinated Universal Time (UTC) (formerly known as Greenwich Mean Time (GMT)).

The time set on the computer with the QNX date command reflects Coordinated Universal Time. The environment variable TZ is used to establish the local time zone. See the Global Data and the TZ Environment Variable chapter for a discussion of how to set the time zone.

Returns:

A pointer to the string containing the local time.

Examples:

#include <stdio.h>
#include <time.h>

void main()
  {
    time_t time_of_day;
    char buf[26];

    time_of_day = time( NULL );
    printf( "It is now: %s", 
      _ctime( &time_of_day, buf ) );
  }

produces the output:

It is now: Fri Dec 25 15:58:42 1987

Classification:

WATCOM
Safety:
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

asctime(), clock(), ctime(), difftime(), gmtime(), localtime(), mktime(), strftime(), time(), tzset()


[Previous]
[Contents]
[Next]