os/ossrv/genericopenlibs/cstdlib/LTIME/GMTIME.C
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
/*
sl@0
     2
* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     3
* All rights reserved.
sl@0
     4
* This component and the accompanying materials are made available
sl@0
     5
* under the terms of "Eclipse Public License v1.0"
sl@0
     6
* which accompanies this distribution, and is available
sl@0
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     8
*
sl@0
     9
* Initial Contributors:
sl@0
    10
* Nokia Corporation - initial contribution.
sl@0
    11
*
sl@0
    12
* Contributors:
sl@0
    13
*
sl@0
    14
* Description:
sl@0
    15
* FUNCTION
sl@0
    16
* <<gmtime>>---convert time to UTC traditional form
sl@0
    17
* INDEX
sl@0
    18
* gmtime
sl@0
    19
* ANSI_SYNOPSIS
sl@0
    20
* #include <time.h>
sl@0
    21
* struct tm *gmtime(const time_t *<[clock]>);
sl@0
    22
* struct tm *gmtime_r(const time_t *<[clock]>, struct tm *<[res]>);
sl@0
    23
* TRAD_SYNOPSIS
sl@0
    24
* #include <time.h>
sl@0
    25
* struct tm *gmtime(<[clock]>)
sl@0
    26
* const time_t *<[clock]>;
sl@0
    27
* struct tm *gmtime_r(<[clock]>, <[res]>)
sl@0
    28
* const time_t *<[clock]>;
sl@0
    29
* struct tm *<[res]>;
sl@0
    30
* <<gmtime>> assumes the time at <[clock]> represents a local time.
sl@0
    31
* <<gmtime>> converts it to UTC (Universal Coordinated Time, also known in some
sl@0
    32
* countries as GMT, Greenwich Mean time), then converts the
sl@0
    33
* representation from the arithmetic representation to
sl@0
    34
* the traditional representation defined by <<struct tm>>.
sl@0
    35
* <<gmtime>> constructs the traditional time representation in static
sl@0
    36
* storage; each call to <<gmtime>> or <<localtime>> will overwrite the
sl@0
    37
* information generated by previous calls to either function.
sl@0
    38
* RETURNS
sl@0
    39
* A pointer to the traditional time representation (<<struct tm>>).
sl@0
    40
* PORTABILITY
sl@0
    41
* ANSI C requires <<gmtime>>.
sl@0
    42
* <<gmtime>> requires no supporting OS subroutines.
sl@0
    43
* 
sl@0
    44
*
sl@0
    45
*/
sl@0
    46
sl@0
    47
sl@0
    48
sl@0
    49
#include <sys/reent.h>
sl@0
    50
#include <time.h>
sl@0
    51
sl@0
    52
#ifndef _REENT_ONLY
sl@0
    53
sl@0
    54
/**
sl@0
    55
Convert time_t value to tm structure as UTC time.
sl@0
    56
Converts timer to tm structure adjusting to 
sl@0
    57
UTC (formerly known as GMT) timezone.  
sl@0
    58
@return A pointer to a tm structure.
sl@0
    59
This structure is statically allocated and shared by gmtime,
sl@0
    60
localtime and ctime functions. 
sl@0
    61
Each time one of these functions is called the content of
sl@0
    62
the structure is overwritten.
sl@0
    63
@param tim_p pointer to a time_t value, 
sl@0
    64
usually returned by time function.
sl@0
    65
*/
sl@0
    66
EXPORT_C struct tm *
sl@0
    67
gmtime (const time_t * tim_p)
sl@0
    68
{
sl@0
    69
  return gmtime_r (tim_p, &(_REENT->_struct_tm));
sl@0
    70
}
sl@0
    71
sl@0
    72
#endif