diff options
author | Christopher Faylor <cgf@redhat.com> | 2000-02-17 19:39:46 +0000 |
---|---|---|
committer | Christopher Faylor <cgf@redhat.com> | 2000-02-17 19:39:46 +0000 |
commit | 6d491d8ad9122891d1a48447e8c49702eb678921 (patch) | |
tree | 45619a131b9f211ceca9fce7a866328344bf00ec /newlib/libc/time/gmtime.c | |
parent | bd592806f45307757c24ec3f75bdefe13abfd51f (diff) | |
download | gdb-cvs/SNAPSHOT.tar.gz |
import newlib-2000-02-17 snapshotcvs/SNAPSHOT
Diffstat (limited to 'newlib/libc/time/gmtime.c')
-rw-r--r-- | newlib/libc/time/gmtime.c | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/newlib/libc/time/gmtime.c b/newlib/libc/time/gmtime.c new file mode 100644 index 00000000000..4f5bbe40344 --- /dev/null +++ b/newlib/libc/time/gmtime.c @@ -0,0 +1,67 @@ +/* + * gmtime.c + * Original Author: G. Haley + * + * Converts the calendar time pointed to by tim_p into a broken-down time + * expressed as Greenwich Mean Time (GMT). Returns a pointer to a structure + * containing the broken-down time, or a null pointer if GMT is not + * available. + */ + +/* +FUNCTION +<<gmtime>>---convert time to UTC traditional form + +INDEX + gmtime + +ANSI_SYNOPSIS + #include <time.h> + struct tm *gmtime(const time_t *<[clock]>); + struct tm *gmtime_r(const time_t *<[clock]>, struct tm *<[res]>); + +TRAD_SYNOPSIS + #include <time.h> + struct tm *gmtime(<[clock]>) + const time_t *<[clock]>; + struct tm *gmtime_r(<[clock]>, <[res]>) + const time_t *<[clock]>; + struct tm *<[res]>; + +DESCRIPTION +<<gmtime>> assumes the time at <[clock]> represents a local time. +<<gmtime>> converts it to UTC (Universal Coordinated Time, also known in some +countries as GMT, Greenwich Mean time), then converts the +representation from the arithmetic representation to +the traditional representation defined by <<struct tm>>. + +<<gmtime>> constructs the traditional time representation in static +storage; each call to <<gmtime>> or <<localtime>> will overwrite the +information generated by previous calls to either function. + +RETURNS +A pointer to the traditional time representation (<<struct tm>>). + +PORTABILITY +ANSI C requires <<gmtime>>. + +<<gmtime>> requires no supporting OS subroutines. +*/ + +#include <stdlib.h> +#include <time.h> + +#define _GMT_OFFSET 0 + +#ifndef _REENT_ONLY + +struct tm * +_DEFUN (gmtime, (tim_p), + _CONST time_t * tim_p) +{ + time_t tim = *tim_p + _GMT_OFFSET; + + return (localtime (&tim)); +} + +#endif |