head 1.4; access; symbols; locks; strict; comment @# @; 1.4 date 2002.09.07.01.50.38; author curt; state Exp; branches; next 1.3; 1.3 date 2002.08.31.19.01.55; author curt; state Exp; branches; next 1.2; 1.2 date 2002.08.31.18.54.01; author curt; state Exp; branches; next 1.1; 1.1 date 2002.02.15.17.21.57; author curt; state Exp; branches; next ; desc @@ 1.4 log @Updated doxygen docs. @ text @
Main Page Class Hierarchy Compound List File List Compound Members File Members

# lowleveltime.h

    00001 /* -*- Mode: C++ -*- *****************************************************
    00002  * lowleveltime.h
    00003  * Written by various people (I"ll look up the exact credits later)
    00004  * Modified by Durk Talsma, July 1999 for use in FlightGear
    00005  *
    00006  * This library is free software; you can redistribute it and/or
    00007  * modify it under the terms of the GNU Library General Public
    00008  * License as published by the Free Software Foundation; either
    00009  * version 2 of the License, or (at your option) any later version.
    00010  *
    00011  * This library is distributed in the hope that it will be useful,
    00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00014  * Library General Public License for more details.
    00015  *
    00016  * You should have received a copy of the GNU Library General Public
    00017  * License along with this library; if not, write to the
    00018  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00019  * Boston, MA  02111-1307, USA.
    00020  *
    00021  **************************************************************************/
    00022
    00023 /********************************************************************
    00024  * This file redefines some low-level Unix-like time functions for  *
    00025  * use with FlightGear. Most notably, localtime() is adapted to use *
    00026  * a custom timezone, in order to get the 'local' time for a given  *
    00027  * aircraft's position, and not only for the current location of the*
    00028  * computer running the sim.                                        *
    00029  *                                                                  *
    00030  * Software adapted from glibc functions, by Durk Talsma. Started   *
    00031  * July, 17, 1999.                                                  *
    00032  ********************************************************************/
    00033
    00034 #ifndef _LOWLEVELTIME_H_
    00035 #define _LOWLEVELTIME_H_
    00036
    00037 #include <time.h>
    00038
    00039 /* adapted from zdump.c */
    00040 void show (const char *zone, time_t t, int v);
    00041
    00042 /* adapted from <time.h> */
    00043 struct tm * fgLocaltime (const time_t *t, const char *tzName);
    00044
    00045 /* Prototype for the internal function to get information based on TZ.  */
    00046 extern struct tm *fgtz_convert (const time_t *t, int use_localtime,
    00047                                      struct tm *tp, const char *tzName);
    00048
    00049 /* This structure contains all the information about a
    00050    timezone given in the POSIX standard TZ envariable.  */
    00051 typedef struct
    00052   {
    00053     const char *name;
    00054
    00055     /* When to change.  */
    00056     enum { J0, J1, M } type;    /* Interpretation of:  */
    00057     unsigned short int m, n, d; /* Month, week, day.  */
    00058     unsigned int secs;          /* Time of day.  */
    00059
    00060     long int offset;            /* Seconds east of GMT (west if < 0).  */
    00061
    00062     /* We cache the computed time of change for a
    00063        given year so we don't have to recompute it.  */
    00064     time_t change;      /* When to change to this zone.  */
    00065     int computed_for;   /* Year above is computed for.  */
    00066   } fgtz_rule;
    00067
    00068 struct tzhead {
    00069         char    tzh_magic[4];           /* TZ_MAGIC */
    00070         char    tzh_reserved[16];       /* reserved for future use */
    00071         char    tzh_ttisgmtcnt[4];      /* coded number of trans. time flags */
    00072         char    tzh_ttisstdcnt[4];      /* coded number of trans. time flags */
    00073         char    tzh_leapcnt[4];         /* coded number of leap seconds */
    00074         char    tzh_timecnt[4];         /* coded number of transition times */
    00075         char    tzh_typecnt[4];         /* coded number of local time types */
    00076         char    tzh_charcnt[4];         /* coded number of abbr. chars */
    00077 };
    00078
    00079
    00080 /* Defined in mktime.c.  */
    00081 extern const unsigned short int mon_yday[2][13];
    00082
    00083 #ifndef TZDIR
    00084 #define TZDIR   "/usr/local/etc/zoneinfo" /* Time zone object file directory */
    00085 #endif /* !defined TZDIR */
    00086
    00087
    00088
    00089 #ifndef TZDEFAULT
    00090 #define TZDEFAULT       "localtime"
    00091 #endif /* !defined TZDEFAULT */
    00092
    00093 #define SECSPERMIN      60
    00094 #define MINSPERHOUR     60
    00095 #define HOURSPERDAY     24
    00096 #define DAYSPERWEEK     7
    00097 #define DAYSPERNYEAR    365
    00098 #define DAYSPERLYEAR    366
    00099 #define SECSPERHOUR     (SECSPERMIN * MINSPERHOUR)
    00100 #define SECSPERDAY      ((long) SECSPERHOUR * HOURSPERDAY)
    00101 #define MONSPERYEAR     12
    00102
    00103 #define TM_SUNDAY       0
    00104 #define TM_MONDAY       1
    00105 #define TM_TUESDAY      2
    00106 #define TM_WEDNESDAY    3
    00107 #define TM_THURSDAY     4
    00108 #define TM_FRIDAY       5
    00109 #define TM_SATURDAY     6
    00110
    00111 #define TM_JANUARY      0
    00112 #define TM_FEBRUARY     1
    00113 #define TM_MARCH        2
    00114 #define TM_APRIL        3
    00115 #define TM_MAY          4
    00116 #define TM_JUNE         5
    00117 #define TM_JULY         6
    00118 #define TM_AUGUST       7
    00119 #define TM_SEPTEMBER    8
    00120 #define TM_OCTOBER      9
    00121 #define TM_NOVEMBER     10
    00122 #define TM_DECEMBER     11
    00123
    00124 #define TM_YEAR_BASE    1900
    00125
    00126 #define EPOCH_YEAR      1970
    00127 #define EPOCH_WDAY      TM_THURSDAY
    00128
    00129 #endif

@ 1.3 log @Oops, try again. @ text @d138 1 a138 1