XML Schema Datetime and Decimals

## XML Schema Datetime and Decimals XML Schema Datetime and Decimals — XML Schema datetime and arbitrary length decimal number arithmetic. |

## Functions

rasqal_xsd_date * | rasqal_new_xsd_date ()
void | rasqal_free_xsd_date ()
char * | rasqal_xsd_date_to_counted_string ()
char * | rasqal_xsd_date_to_string ()
int | rasqal_xsd_date_equals ()
int | rasqal_xsd_date_compare ()
#define | RASQAL_XSD_DATETIME_NO_TZ
rasqal_xsd_datetime * | rasqal_new_xsd_datetime ()
rasqal_xsd_datetime * | rasqal_new_xsd_datetime_from_timeval ()
rasqal_xsd_datetime * | rasqal_new_xsd_datetime_from_unixtime ()
rasqal_xsd_datetime * | rasqal_new_xsd_datetime_from_xsd_date ()
void | rasqal_free_xsd_datetime ()
int | rasqal_xsd_datetime_compare ()
int | rasqal_xsd_datetime_compare2 ()
int | rasqal_xsd_datetime_equals ()
int | rasqal_xsd_datetime_equals2 ()
struct timeval * | rasqal_xsd_datetime_get_as_timeval ()
time_t | rasqal_xsd_datetime_get_as_unixtime ()
rasqal_xsd_decimal * | rasqal_xsd_datetime_get_seconds_as_decimal ()
char * | rasqal_xsd_datetime_get_timezone_as_counted_string ()
char * | rasqal_xsd_datetime_get_tz_as_counted_string ()
int | rasqal_xsd_datetime_set_from_timeval ()
int | rasqal_xsd_datetime_set_from_unixtime ()
char * | rasqal_xsd_datetime_to_counted_string ()
char * | rasqal_xsd_datetime_to_string ()
void | rasqal_free_xsd_decimal ()
rasqal_xsd_decimal * | rasqal_new_xsd_decimal ()
int | rasqal_xsd_decimal_abs ()
int | rasqal_xsd_decimal_add ()
char * | rasqal_xsd_decimal_as_counted_string ()
char * | rasqal_xsd_decimal_as_string ()
int | rasqal_xsd_decimal_ceil ()
int | rasqal_xsd_decimal_compare ()
int | rasqal_xsd_decimal_divide ()
int | rasqal_xsd_decimal_equals ()
int | rasqal_xsd_decimal_floor ()
double | rasqal_xsd_decimal_get_double ()
long | rasqal_xsd_decimal_get_long ()
int | rasqal_xsd_decimal_is_zero ()
int | rasqal_xsd_decimal_multiply ()
int | rasqal_xsd_decimal_negate ()
int | rasqal_xsd_decimal_print ()
int | rasqal_xsd_decimal_round ()
int | rasqal_xsd_decimal_set_double ()
int | rasqal_xsd_decimal_set_long ()
int | rasqal_xsd_decimal_set_string ()
int | rasqal_xsd_decimal_subtract ()

## Types and Values

| rasqal_xsd_date
| rasqal_xsd_datetime
typedef | rasqal_xsd_decimal

## Description

Classes for providing XSD datatypes for Datetimes plus Decimals with arbitrary length floating point decimals and standard operators on the Decimals suitable for SPARQL.

## Functions

### rasqal_new_xsd_date ()

    rasqal_xsd_date *
    rasqal_new_xsd_date (rasqal_world *world,
                         const char *date_string);

#### Returns

### rasqal_free_xsd_date ()

    void
    rasqal_free_xsd_date (rasqal_xsd_date *d);

### rasqal_xsd_date_to_counted_string ()

    char *
    rasqal_xsd_date_to_counted_string (const rasqal_xsd_date *date,
                                       size_t *len_p);

#### Returns

### rasqal_xsd_date_to_string ()

    char *
    rasqal_xsd_date_to_string (const rasqal_xsd_date *d);

#### Returns

### rasqal_xsd_date_equals ()

    int
    rasqal_xsd_date_equals (const rasqal_xsd_date *d1,
                            const rasqal_xsd_date *d2,
                            int *incomparible_p);

#### Returns

### rasqal_xsd_date_compare ()

    int
    rasqal_xsd_date_compare (const rasqal_xsd_date *d1,
                             const rasqal_xsd_date *d2,
                             int *incomparible_p);

#### Returns

### RASQAL_XSD_DATETIME_NO_TZ

    #define RASQAL_XSD_DATETIME_NO_TZ (9999)

Sentinel XSD Decimal timezone value indicating no timezone is present.

### rasqal_new_xsd_datetime ()

    rasqal_xsd_datetime *
    rasqal_new_xsd_datetime (rasqal_world *world,
                             const char *datetime_string);

#### Returns

### rasqal_new_xsd_datetime_from_timeval ()

    rasqal_xsd_datetime *
    rasqal_new_xsd_datetime_from_timeval (rasqal_world *world,
                                          struct timeval *tv);

#### Returns

### rasqal_new_xsd_datetime_from_unixtime ()

    rasqal_xsd_datetime *
    rasqal_new_xsd_datetime_from_unixtime (rasqal_world *world,
                                           time_t secs);

#### Returns

### rasqal_new_xsd_datetime_from_xsd_date ()

    rasqal_xsd_datetime *
    rasqal_new_xsd_datetime_from_xsd_date (rasqal_world *world,
                                           rasqal_xsd_date *date);

#### Returns

### rasqal_free_xsd_datetime ()

    void
    rasqal_free_xsd_datetime (rasqal_xsd_datetime *dt);

### rasqal_xsd_datetime_compare ()

    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.

#### Returns

### rasqal_xsd_datetime_compare2 ()

    int
    rasqal_xsd_datetime_compare2 (const rasqal_xsd_datetime *dt1,
                                  const rasqal_xsd_datetime *dt2,
                                  int *incomparible_p);

#### Returns

### rasqal_xsd_datetime_equals ()

    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.

#### Returns

### rasqal_xsd_datetime_equals2 ()

    int
    rasqal_xsd_datetime_equals2 (const rasqal_xsd_datetime *dt1,
                                 const rasqal_xsd_datetime *dt2,
                                 int *incomparible_p);

#### Returns

### rasqal_xsd_datetime_get_as_timeval ()

    struct timeval *
    rasqal_xsd_datetime_get_as_timeval (rasqal_xsd_datetime *dt);

#### Returns

### rasqal_xsd_datetime_get_as_unixtime ()

    time_t
    rasqal_xsd_datetime_get_as_unixtime (rasqal_xsd_datetime *dt);

#### Returns

### rasqal_xsd_datetime_get_seconds_as_decimal ()

    rasqal_xsd_decimal *
    rasqal_xsd_datetime_get_seconds_as_decimal
                                   (rasqal_world *world,
                                    rasqal_xsd_datetime *dt);

#### Returns

### rasqal_xsd_datetime_get_timezone_as_counted_string ()

    char *
    rasqal_xsd_datetime_get_timezone_as_counted_string
                                   (rasqal_xsd_datetime *dt,
                                    size_t *len_p);

#### Returns

### rasqal_xsd_datetime_get_tz_as_counted_string ()

    char *
    rasqal_xsd_datetime_get_tz_as_counted_string
                                   (rasqal_xsd_datetime *dt,
                                    size_t *len_p);

#### Returns

### rasqal_xsd_datetime_set_from_timeval ()

    int
    rasqal_xsd_datetime_set_from_timeval (rasqal_xsd_datetime *dt,
                                          struct timeval *tv);

#### Returns

### rasqal_xsd_datetime_set_from_unixtime ()

    int
    rasqal_xsd_datetime_set_from_unixtime (rasqal_xsd_datetime *dt,
                                           time_t clock);

#### Returns

### rasqal_xsd_datetime_to_counted_string ()

    char *
    rasqal_xsd_datetime_to_counted_string (const rasqal_xsd_datetime *dt,
                                           size_t *len_p);

#### Returns

### rasqal_xsd_datetime_to_string ()

    char *
    rasqal_xsd_datetime_to_string (const rasqal_xsd_datetime *dt);

#### Returns

### rasqal_free_xsd_decimal ()

    void
    rasqal_free_xsd_decimal (rasqal_xsd_decimal *dec);

### rasqal_new_xsd_decimal ()

    rasqal_xsd_decimal *
    rasqal_new_xsd_decimal (rasqal_world *world);

#### Returns

### rasqal_xsd_decimal_abs ()

    int
    rasqal_xsd_decimal_abs (rasqal_xsd_decimal *result,
                            rasqal_xsd_decimal *a);

#### Returns

### rasqal_xsd_decimal_add ()

    int
    rasqal_xsd_decimal_add (rasqal_xsd_decimal *result,
                            rasqal_xsd_decimal *a,
                            rasqal_xsd_decimal *b);

#### Returns

### rasqal_xsd_decimal_as_counted_string ()

    char *
    rasqal_xsd_decimal_as_counted_string (rasqal_xsd_decimal *dec,
                                          size_t *len_p);

#### Returns

### rasqal_xsd_decimal_as_string ()

    char *
    rasqal_xsd_decimal_as_string (rasqal_xsd_decimal *dec);

#### Returns

### rasqal_xsd_decimal_ceil ()

    int
    rasqal_xsd_decimal_ceil (rasqal_xsd_decimal *result,
                             rasqal_xsd_decimal *a);

#### Returns

### rasqal_xsd_decimal_compare ()

    int
    rasqal_xsd_decimal_compare (rasqal_xsd_decimal *a,
                                rasqal_xsd_decimal *b);

#### Returns

### rasqal_xsd_decimal_divide ()

    int
    rasqal_xsd_decimal_divide (rasqal_xsd_decimal *result,
                               rasqal_xsd_decimal *a,
                               rasqal_xsd_decimal *b);

#### Returns

### rasqal_xsd_decimal_equals ()

    int
    rasqal_xsd_decimal_equals (rasqal_xsd_decimal *a,
                               rasqal_xsd_decimal *b);

#### Returns

### rasqal_xsd_decimal_floor ()

    int
    rasqal_xsd_decimal_floor (rasqal_xsd_decimal *result,
                              rasqal_xsd_decimal *a);

#### Returns

### rasqal_xsd_decimal_get_double ()

    double
    rasqal_xsd_decimal_get_double (rasqal_xsd_decimal *dec);

#### Returns

### rasqal_xsd_decimal_get_long ()

    long
    rasqal_xsd_decimal_get_long (rasqal_xsd_decimal *dec,
                                 int *error_p);

#### Returns

### rasqal_xsd_decimal_is_zero ()

    int
    rasqal_xsd_decimal_is_zero (rasqal_xsd_decimal *d);

#### Returns

### rasqal_xsd_decimal_multiply ()

    int
    rasqal_xsd_decimal_multiply (rasqal_xsd_decimal *result,
                                 rasqal_xsd_decimal *a,
                                 rasqal_xsd_decimal *b);

#### Returns

### rasqal_xsd_decimal_negate ()

    int
    rasqal_xsd_decimal_negate (rasqal_xsd_decimal *result,
                               rasqal_xsd_decimal *a);

#### Returns

### rasqal_xsd_decimal_print ()

    int
    rasqal_xsd_decimal_print (rasqal_xsd_decimal *dec,
                              FILE *stream);

#### Returns

### rasqal_xsd_decimal_round ()

    int
    rasqal_xsd_decimal_round (rasqal_xsd_decimal *result,
                              rasqal_xsd_decimal *a);

#### Returns

### rasqal_xsd_decimal_set_double ()

    int
    rasqal_xsd_decimal_set_double (rasqal_xsd_decimal *dec,
                                   double d);

#### Returns

### rasqal_xsd_decimal_set_long ()

    int
    rasqal_xsd_decimal_set_long (rasqal_xsd_decimal *dec,
                                 long l Param2);

#### Returns

### rasqal_xsd_decimal_set_string ()

    int
    rasqal_xsd_decimal_set_string (rasqal_xsd_decimal *dec,
                                   const char *string);

#### Returns

### rasqal_xsd_decimal_subtract ()

    int
    rasqal_xsd_decimal_subtract (rasqal_xsd_decimal *result,
                                 rasqal_xsd_decimal *a,
                                 rasqal_xsd_decimal *b);

#### Returns

## Types and Values

### rasqal_xsd_date

    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'

#### Members

signed int `year`; | year |
unsigned char `month`; | month 1-12 |
unsigned char `day`; | 1-31 |
signed short `timezone_minutes`; | minutes +/- against UTC or RASQAL_XSD_DATETIME_NO_TZ if there is no timezone in the dateTime. |
time_t `time_on_timeline`; | time on timeline of first instant of date in timezone |
char `have_tz`; | timezone flag: 'Z' if Zulu, 'Y' if has other timezone offset in `timezone_minutes` , 'N' if there is no timezone |

### rasqal_xsd_datetime

    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'

#### Members

signed int `year`; | year |
unsigned char `month`; | month 1-12 |
unsigned char `day`; | 1-31 |
signed char `hour`; | hour 0-23 |
signed char `minute`; | minute 0-59 |
signed char `second`; | second 0-60 (yes 60 is allowed for leap seconds) |
signed int `microseconds`; | microseconds |
signed short `timezone_minutes`; | minutes +/- against UTC or RASQAL_XSD_DATETIME_NO_TZ if there is no timezone in the dateTime. |
time_t `time_on_timeline`; | time on timeline |
char `have_tz`; | timezone flag: 'Z' if Zulu, 'Y' if has other timezone offset in `timezone_minutes` , 'N' if there is no timezone |

### rasqal_xsd_decimal

    typedef struct rasqal_xsd_decimal_s rasqal_xsd_decimal;

Rasqal XSD Decimal class.