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