From 40e5a5811c6ffce9b0974e93cdd927cbcf60c157 Mon Sep 17 00:00:00 2001 From: Joe Hunkeler Date: Tue, 11 Aug 2015 16:51:37 -0400 Subject: Repatch (from linux) of OSX IRAF --- unix/os/zgmtco.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 unix/os/zgmtco.c (limited to 'unix/os/zgmtco.c') diff --git a/unix/os/zgmtco.c b/unix/os/zgmtco.c new file mode 100644 index 00000000..03fa5db8 --- /dev/null +++ b/unix/os/zgmtco.c @@ -0,0 +1,49 @@ +/* Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + */ + +#include +#include +#include + +#define import_kernel +#define import_knames +#define import_spp +#include + +#define SECONDS_1970_TO_1980 315532800L + + +/* ZGMTCO -- Return the correction, in seconds, from local standard time + * (clock time) to GMT. GMT = LST + gmtco (seconds), or gmtco = GMT-LST. + */ +int +ZGMTCO ( + XINT *gmtcor /* seconds */ +) +{ + time_t gmt_to_lst(), ltime; + + /* Given an input value of zero (biased by SECONDS_1970_TO_1980) + * gmt_to_lst will return a negative value in seconds for a location + * in the US (as an limiting test case). We want to return the + * correction to LST to get GMT, a positive value for the US, so + * we need to negate this value. gmt_to_lst will already have taken + * daylight savings time into account. Although we talk about the + * US (as a test case) this relation will hold both east and west + * of Greenwich. + */ + + *gmtcor = -((XINT) gmt_to_lst ((time_t) SECONDS_1970_TO_1980)); + + + /* Daylight saving time is not added to the output of gmt_to_lst() + * since it assumes Jan 1. Use the current date to determin if + * DST is in effect. + */ + + ltime = time(0); + if (localtime(<ime)->tm_isdst) + *gmtcor = *gmtcor - 60L * 60L; + + return (XOK); +} -- cgit