Top | ![]() |
![]() |
![]() |
![]() |
rasqal_xsd_date * rasqal_new_xsd_date (rasqal_world *world
,const char *date_string
);
Constructor - make a new XSD date object from a string
char * rasqal_xsd_date_to_counted_string (const rasqal_xsd_date *date
,size_t *len_p
);
Convert a rasqal_xsd_date struct to a xsd:date lexical form string.
Caller should rasqal_free_memory()
the returned string.
See http://www.w3.org/TR/xmlschema-2/date-canonical-representation
char *
rasqal_xsd_date_to_string (const rasqal_xsd_date *d
);
Convert a rasqal_xsd_date struct to a xsd:date lexical form string.
Caller should rasqal_free_memory()
the returned string.
int rasqal_xsd_date_equals (const rasqal_xsd_date *d1
,const rasqal_xsd_date *d2
,int *incomparible_p
);
Compare two XSD dates for equality.
int rasqal_xsd_date_compare (const rasqal_xsd_date *d1
,const rasqal_xsd_date *d2
,int *incomparible_p
);
Compare two XSD dates
If the only one of the two dates have timezones, the results
may be incomparible and that will return >0 and set the
value of the int point to by incomparible_p
to non-0
#define RASQAL_XSD_DATETIME_NO_TZ (9999)
Sentinel XSD Decimal timezone value indicating no timezone is present.
rasqal_xsd_datetime * rasqal_new_xsd_datetime (rasqal_world *world
,const char *datetime_string
);
Constructor - make a new XSD datetime object from a string
rasqal_xsd_datetime * rasqal_new_xsd_datetime_from_timeval (rasqal_world *world
,struct timeval *tv
);
Constructor - make a new XSD datetime object from a timeval
rasqal_xsd_datetime * rasqal_new_xsd_datetime_from_unixtime (rasqal_world *world
,time_t secs
);
Constructor - make a new XSD datetime object from unixtime seconds
rasqal_xsd_datetime * rasqal_new_xsd_datetime_from_xsd_date (rasqal_world *world
,rasqal_xsd_date *date
);
Constructor - make a new XSD datetime object from an XSD date
void
rasqal_free_xsd_datetime (rasqal_xsd_datetime *dt
);
Destroy XSD datetime object.
int rasqal_xsd_datetime_compare (const rasqal_xsd_datetime *dt1
,const rasqal_xsd_datetime *dt2
);
rasqal_xsd_datetime_compare
is deprecated and should not be used in newly-written code.
Compare two XSD dateTimes
Deprecated
for rasqal_xsd_datetime_compare2()
which can return the incomparible result.
int rasqal_xsd_datetime_compare2 (const rasqal_xsd_datetime *dt1
,const rasqal_xsd_datetime *dt2
,int *incomparible_p
);
Compare two XSD dateTimes
If the only one of the two dateTimes have timezones, the results
may be incomparible and that will return >0 and set the
value of the int point to by incomparible_p
to non-0
int rasqal_xsd_datetime_equals (const rasqal_xsd_datetime *dt1
,const rasqal_xsd_datetime *dt2
);
rasqal_xsd_datetime_equals
is deprecated and should not be used in newly-written code.
Compare two XSD dateTimes for equality.
Deprecated
: for rasqal_xsd_datetime_equals2 that returns incomparibility.
int rasqal_xsd_datetime_equals2 (const rasqal_xsd_datetime *dt1
,const rasqal_xsd_datetime *dt2
,int *incomparible_p
);
Compare two XSD dateTimes for equality.
struct timeval *
rasqal_xsd_datetime_get_as_timeval (rasqal_xsd_datetime *dt
);
Get a datetime as struct timeval
The returned timeval must be freed by the caller such as using
rasqal_free_memory()
.
time_t
rasqal_xsd_datetime_get_as_unixtime (rasqal_xsd_datetime *dt
);
Get a datetime as unix seconds
rasqal_xsd_decimal * rasqal_xsd_datetime_get_seconds_as_decimal (rasqal_world *world
,rasqal_xsd_datetime *dt
);
Get the seconds component of a dateTime as a decimal
char * rasqal_xsd_datetime_get_timezone_as_counted_string (rasqal_xsd_datetime *dt
,size_t *len_p
);
Get the timezone of a datetime as a duration format string with optional length count
The returned string is owned by the caller and must be freed
by rasqal_free_memory()
.
char * rasqal_xsd_datetime_get_tz_as_counted_string (rasqal_xsd_datetime *dt
,size_t *len_p
);
Get the timezone of a datetime as a timezone string
The returned string is owned by the caller and must be freed
by rasqal_free_memory()
.
int rasqal_xsd_datetime_set_from_timeval (rasqal_xsd_datetime *dt
,struct timeval *tv
);
Set an XSD dateTime from a struct timeval pointer
int rasqal_xsd_datetime_set_from_unixtime (rasqal_xsd_datetime *dt
,time_t clock
);
Set an XSD dateTime from unixtime seconds
char * rasqal_xsd_datetime_to_counted_string (const rasqal_xsd_datetime *dt
,size_t *len_p
);
Convert a rasqal_xsd_datetime struct to a xsd:dateTime lexical form counted string.
Caller should rasqal_free_memory()
the returned string.
See http://www.w3.org/TR/xmlschema-2/dateTime-canonical-representation
char *
rasqal_xsd_datetime_to_string (const rasqal_xsd_datetime *dt
);
Convert a rasqal_xsd_datetime struct to a xsd:dateTime lexical form string.
Caller should rasqal_free_memory()
the returned string.
void
rasqal_free_xsd_decimal (rasqal_xsd_decimal *dec
);
Destroy XSD Decimal object.
rasqal_xsd_decimal *
rasqal_new_xsd_decimal (rasqal_world *world
);
Create a new XSD Decimal object.
int rasqal_xsd_decimal_abs (rasqal_xsd_decimal *result
,rasqal_xsd_decimal *a
);
Return the absolute value of an XSD Decimal
int rasqal_xsd_decimal_add (rasqal_xsd_decimal *result
,rasqal_xsd_decimal *a
,rasqal_xsd_decimal *b
);
Add two XSD Decimals and store in result XSD Decimal
char * rasqal_xsd_decimal_as_counted_string (rasqal_xsd_decimal *dec
,size_t *len_p
);
Get an XSD Decimal as a string lexical form with optional length.
The returned string is shared and owned by the dec
object and
must be copied. If len_p
is not NULL, the length of the returned
string is stored.
char *
rasqal_xsd_decimal_as_string (rasqal_xsd_decimal *dec
);
Get an XSD Decimal as a string lexical form.
The returned string is shared and owned by the dec
object and
must be copied.
int rasqal_xsd_decimal_ceil (rasqal_xsd_decimal *result
,rasqal_xsd_decimal *a
);
Return the number with no fractional part closes to argument for an XSD Decimal
int rasqal_xsd_decimal_compare (rasqal_xsd_decimal *a
,rasqal_xsd_decimal *b
);
Compare two XSD Decimals
int rasqal_xsd_decimal_divide (rasqal_xsd_decimal *result
,rasqal_xsd_decimal *a
,rasqal_xsd_decimal *b
);
Divide two XSD Decimals and store in result XSD Decimal
If the divisor b
is 0, failure is returned
int rasqal_xsd_decimal_equals (rasqal_xsd_decimal *a
,rasqal_xsd_decimal *b
);
Compare two XSD Decimals for equality.
int rasqal_xsd_decimal_floor (rasqal_xsd_decimal *result
,rasqal_xsd_decimal *a
);
Return the number with no fractional part closes to argument for an XSD Decimal
double
rasqal_xsd_decimal_get_double (rasqal_xsd_decimal *dec
);
Get an XSD Decimal as a double (may lose precision)
long rasqal_xsd_decimal_get_long (rasqal_xsd_decimal *dec
,int *error_p
);
Get an XSD Decimal as a long (may lose precision)
int
rasqal_xsd_decimal_is_zero (rasqal_xsd_decimal *d
);
Test if an XSD decimal is zero.
int rasqal_xsd_decimal_multiply (rasqal_xsd_decimal *result
,rasqal_xsd_decimal *a
,rasqal_xsd_decimal *b
);
Multiply two XSD Decimals and store in result XSD Decimal
int rasqal_xsd_decimal_negate (rasqal_xsd_decimal *result
,rasqal_xsd_decimal *a
);
Negate an XSD Decimal
int rasqal_xsd_decimal_print (rasqal_xsd_decimal *dec
,FILE *stream
);
Print an XSD Decimal to a stream
int rasqal_xsd_decimal_round (rasqal_xsd_decimal *result
,rasqal_xsd_decimal *a
);
Return the number with no fractional part closes to argument for an XSD Decimal
int rasqal_xsd_decimal_set_double (rasqal_xsd_decimal *dec
,double d
);
Set an XSD Decimal value from a double.
int rasqal_xsd_decimal_set_long (rasqal_xsd_decimal *dec
,long l Param2
);
Set an XSD Decimal value from a long.
int rasqal_xsd_decimal_set_string (rasqal_xsd_decimal *dec
,const char *string
);
Set an XSD Decimal value from a string lexical form
int rasqal_xsd_decimal_subtract (rasqal_xsd_decimal *result
,rasqal_xsd_decimal *a
,rasqal_xsd_decimal *b
);
Subtract two XSD Decimals and store in result XSD Decimal
typedef struct { signed int year; /* the following fields are integer values not characters */ unsigned char month; unsigned char day; signed short timezone_minutes; time_t time_on_timeline; char have_tz; } rasqal_xsd_date;
XML schema date datatype (xsd:date)
Examples of timezone fields: "2010-01-02" : timezone_minutes RASQAL_XSD_DATETIME_NO_TZ, have_tz 'N' "2010-01-02Z" : timezone_minutes 0, have_tz 'Z' "2010-01-02+00:00" : timezone_minutes 0, have_tz 'Y' "2010-01-02-01:00" : timezone_minutes -60, have_tz 'Y'
typedef struct { signed int year; unsigned char month; unsigned char day; /* the following fields are integer values not characters */ signed char hour; signed char minute; signed char second; signed int microseconds; signed short timezone_minutes; time_t time_on_timeline; char have_tz; } rasqal_xsd_datetime;
XML Schema dateTime datatype (xsd:dateTime)
Signed types are required for normalization process where a value can be negative temporarily.
Examples of timezone fields: "2010-01-02T01:02:03" : timezone_minutes RASQAL_XSD_DATETIME_NO_TZ, have_tz 'N' "2010-01-02T01:02:03Z" : timezone_minutes 0, have_tz 'Z' "2010-01-02T01:02:03+00:00" : timezone_minutes 0, have_tz 'Y' "2010-01-02T01:02:03-01:00" : timezone_minutes -60, have_tz 'Y'
year |
||
month 1-12 |
||
1-31 |
||
hour 0-23 |
||
minute 0-59 |
||
second 0-60 (yes 60 is allowed for leap seconds) |
||
microseconds |
||
minutes +/- against UTC or RASQAL_XSD_DATETIME_NO_TZ if there is no timezone in the dateTime. |
||
time on timeline |
||
timezone flag: 'Z' if Zulu, 'Y' if has other timezone offset in |