amiga-ntimed/include/clib/timezone_protos.h

102 lines
4.5 KiB
C

//--------------------------------------------------------------------------//
/*
* Copyright (c) 2015 Carsten Larsen
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
//--------------------------------------------------------------------------//
#ifndef _CLIB_TIMEZONE_H
#define _CLIB_TIMEZONE_H
//--------------------------------------------------------------------------//
#include <time.h>
#include <sys/time.h>
#include <sys/types.h>
#include <devices/timer.h>
#include <libraries/locale.h>
//--------------------------------------------------------------------------//
#define TZVARIABLE "timezone.prefs"
#define TZDIR "ZONEINFO:"
#define TZDEFAULT "localtime"
#define TZDEFRULES "posixrules"
//--------------------------------------------------------------------------//
#ifndef HAVE_TIMEZONE_T
typedef struct timezone* timezone_t;
#endif
//--------------------------------------------------------------------------//
#ifndef HAVE_LOCATE_T
typedef struct Locale* locale_t;
#endif
//--------------------------------------------------------------------------//
#ifndef _TIME_H_
struct tm {
int tm_sec; /* seconds after the minute [0-61] */
int tm_min; /* minutes after the hour [0-59] */
int tm_hour; /* hours since midnight [0-23] */
int tm_mday; /* day of the month [1-31] */
int tm_mon; /* months since January [0-11] */
int tm_year; /* years since 1900 */
int tm_wday; /* days since Sunday [0-6] */
int tm_yday; /* days since January 1 [0-365] */
int tm_isdst; /* Daylight Savings Time flag */
long tm_gmtoff; /* offset from UTC in seconds */
char *tm_zone; /* timezone abbreviation */
};
#endif
//--------------------------------------------------------------------------//
void tzset(void);
timezone_t tzalloc(char const *name);
void tzfree(timezone_t tz);
time_t time(time_t *p);
time_t mktime(struct tm *tmp);
time_t mktime_z(const timezone_t tz, struct tm *tmp);
struct tm* localtime(const time_t *const timep);
struct tm* localtime_r(const time_t *const timep, struct tm *tmp);
struct tm* localtime_rz(timezone_t tz, time_t const *timep, struct tm *tmp);
struct tm* gmtime(const time_t *timep);
struct tm* gmtime_r(const time_t *timep, struct tm *tmp);
char* ctime(const time_t *const timep);
char* ctime_r(const time_t *const timep, char *buf);
double difftime(const time_t time1, const time_t time0);
char* asctime(const struct tm *timeptr);
char* asctime_r(const struct tm *timeptr, char *buf);
size_t strftime(char * const s, const size_t maxsize,
const char *const format, const struct tm *const t);
size_t strftime_l(char * const s, size_t maxsize,
const char *const format, const struct tm *const t,
locale_t locale);
//--------------------------------------------------------------------------//
void getsystime(struct timeval *tv);
void setsystime(struct timeval *tv);
#ifndef AVOID_TIMEOFDAY
int gettimeofday(struct timeval *tv, const timezone_t tz);
int settimeofday(const struct timeval *tv, const timezone_t tz);
#endif
//--------------------------------------------------------------------------//
int gmtoffset(time_t tloc);
char* tzlocation(void);
void underscore_add(char *s);
void underscore_remove(char *s);
//--------------------------------------------------------------------------//
#endif