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
|
|
|
|
2011-12-31 03:39:20 +01:00
|
|
|
(c) 2000-2012 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
|
|
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __DATE_H
|
|
|
|
#define __DATE_H
|
|
|
|
|
|
|
|
#ifndef GBX_INFO
|
|
|
|
|
|
|
|
#include <sys/time.h>
|
|
|
|
|
|
|
|
#include "gbx_value.h"
|
|
|
|
|
|
|
|
typedef
|
|
|
|
struct {
|
|
|
|
short year;
|
|
|
|
short month;
|
|
|
|
short day;
|
|
|
|
short hour;
|
|
|
|
short min;
|
|
|
|
short sec;
|
|
|
|
short weekday;
|
|
|
|
short msec;
|
|
|
|
}
|
2008-01-17 22:39:26 +01:00
|
|
|
PACKED
|
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
|
|
|
|
|
|
|
|
#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);
|
|
|
|
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
|