2007-12-30 17:41:49 +01:00
|
|
|
/***************************************************************************
|
|
|
|
|
2009-08-17 12:41:51 +02:00
|
|
|
gbx_date.h
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2013-08-03 17:38:01 +02:00
|
|
|
(c) 2000-2013 Benoît Minisini <gambas@users.sourceforge.net>
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2009-08-17 12:41:51 +02:00
|
|
|
the Free Software Foundation; either version 2, or (at your option)
|
2007-12-30 17:41:49 +01:00
|
|
|
any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
2011-06-03 02:51:09 +02:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
2011-12-31 03:39:20 +01:00
|
|
|
MA 02110-1301, USA.
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
2013-01-05 00:24:37 +01:00
|
|
|
#ifndef __GBX_DATE_H
|
|
|
|
#define __GBX_DATE_H
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
#ifndef GBX_INFO
|
|
|
|
|
|
|
|
#include <sys/time.h>
|
|
|
|
|
|
|
|
#include "gbx_value.h"
|
|
|
|
|
|
|
|
typedef
|
|
|
|
struct {
|
2013-10-11 23:06:38 +02:00
|
|
|
int year;
|
|
|
|
int month;
|
|
|
|
int day;
|
|
|
|
int hour;
|
|
|
|
int min;
|
|
|
|
int sec;
|
|
|
|
int weekday;
|
|
|
|
int msec;
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
DATE_SERIAL;
|
|
|
|
|
2010-06-05 01:48:53 +02:00
|
|
|
#ifndef __DATE_DECLARED
|
|
|
|
#define __DATE_DECLARED
|
2007-12-30 17:41:49 +01:00
|
|
|
typedef
|
|
|
|
struct {
|
|
|
|
int date;
|
|
|
|
int time;
|
|
|
|
}
|
|
|
|
DATE;
|
2010-06-05 01:48:53 +02:00
|
|
|
#endif
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
enum {
|
2011-01-01 17:43:40 +01:00
|
|
|
DP_MILLISECOND = 1,
|
|
|
|
DP_SECOND = 2,
|
|
|
|
DP_MINUTE = 3,
|
|
|
|
DP_HOUR = 4,
|
|
|
|
DP_DAY = 5,
|
|
|
|
DP_WEEK = 6,
|
|
|
|
DP_WEEKDAY = 7,
|
|
|
|
DP_MONTH = 8,
|
|
|
|
DP_QUARTER = 9,
|
|
|
|
DP_YEAR = 10,
|
2007-12-30 17:41:49 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#ifndef GBX_INFO
|
2013-01-05 00:24:37 +01:00
|
|
|
|
|
|
|
#ifndef __GBX_DATE_C
|
|
|
|
extern int DATE_timezone;
|
|
|
|
#endif
|
|
|
|
|
2007-12-30 17:41:49 +01:00
|
|
|
#define DATE_YEAR_MIN -4801
|
|
|
|
#define DATE_YEAR_MAX 9999
|
|
|
|
|
|
|
|
#define DATE_NDAY_BC 1753350
|
|
|
|
|
2012-02-05 09:08:27 +01:00
|
|
|
#define DATE_SERIAL_has_no_date(_date) ((_date)->year == 0)
|
|
|
|
#define DATE_SERIAL_has_no_time(_date) ((_date)->hour == 0 && (_date)->min == 0 && (_date)->sec == 0 && (_date)->msec == 0)
|
|
|
|
|
2009-07-08 21:57:50 +02:00
|
|
|
void DATE_init(void);
|
2013-04-10 13:07:38 +02:00
|
|
|
void DATE_init_local(void);
|
2009-07-08 21:57:50 +02:00
|
|
|
DATE_SERIAL *DATE_split(VALUE *value);
|
|
|
|
bool DATE_make(DATE_SERIAL *date, VALUE *val);
|
|
|
|
void DATE_from_time(time_t time, int usec, VALUE *val);
|
|
|
|
void DATE_now(VALUE *val);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-07-08 21:57:50 +02:00
|
|
|
int DATE_to_string(char *buffer, VALUE *value);
|
|
|
|
bool DATE_from_string(const char *str, int len, VALUE *val, bool local);
|
|
|
|
int DATE_comp_value(VALUE *date1, VALUE *date2);
|
|
|
|
int DATE_comp(DATE *date1, DATE *date2);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-08-27 23:09:34 +02:00
|
|
|
double DATE_to_double(struct timeval *time, int from_start);
|
|
|
|
bool DATE_timer(double *result, int from_start);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-07-08 21:57:50 +02:00
|
|
|
void DATE_void_value(VALUE *value);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-07-08 21:57:50 +02:00
|
|
|
void DATE_add(VALUE *date, int period, int val);
|
|
|
|
int DATE_diff(VALUE *date1, VALUE *date2, int period);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|