From 48ef7704c03e7e554c05de01bf8d1d70c16cb6f4 Mon Sep 17 00:00:00 2001 From: ProjectRevoTPP Date: Wed, 20 Dec 2017 16:34:35 -0500 Subject: add libc building to agbcc. --- libc/time/gmtime.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 libc/time/gmtime.c (limited to 'libc/time/gmtime.c') diff --git a/libc/time/gmtime.c b/libc/time/gmtime.c new file mode 100644 index 0000000..4f5bbe4 --- /dev/null +++ b/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 +<>---convert time to UTC traditional form + +INDEX + gmtime + +ANSI_SYNOPSIS + #include + struct tm *gmtime(const time_t *<[clock]>); + struct tm *gmtime_r(const time_t *<[clock]>, struct tm *<[res]>); + +TRAD_SYNOPSIS + #include + struct tm *gmtime(<[clock]>) + const time_t *<[clock]>; + struct tm *gmtime_r(<[clock]>, <[res]>) + const time_t *<[clock]>; + struct tm *<[res]>; + +DESCRIPTION +<> assumes the time at <[clock]> represents a local time. +<> 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 <>. + +<> constructs the traditional time representation in static +storage; each call to <> or <> will overwrite the +information generated by previous calls to either function. + +RETURNS +A pointer to the traditional time representation (<>). + +PORTABILITY +ANSI C requires <>. + +<> requires no supporting OS subroutines. +*/ + +#include +#include + +#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 -- cgit v1.2.3