fx.collections: update header directories
This commit is contained in:
+58
-19
@@ -1,6 +1,6 @@
|
||||
#include <fx/core/stream.h>
|
||||
#include <fx/ds/datetime.h>
|
||||
#include <fx/ds/string.h>
|
||||
#include <fx/collections/datetime.h>
|
||||
#include <fx/collections/string.h>
|
||||
#include <fx/stream.h>
|
||||
|
||||
/*** PRIVATE DATA *************************************************************/
|
||||
|
||||
@@ -89,7 +89,8 @@ static bool is_zone_valid(const struct fx_datetime_p *dt)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(dt->dt_zone_offset_minute >= 0 && dt->dt_zone_offset_minute <= 59)) {
|
||||
if (!(dt->dt_zone_offset_minute >= 0
|
||||
&& dt->dt_zone_offset_minute <= 59)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -309,12 +310,18 @@ fail:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static enum fx_status encode_rfc3339(const struct fx_datetime_p *dt, fx_stream *out)
|
||||
static enum fx_status encode_rfc3339(
|
||||
const struct fx_datetime_p *dt,
|
||||
fx_stream *out)
|
||||
{
|
||||
if (dt->dt_has_date) {
|
||||
fx_stream_write_fmt(
|
||||
out, NULL, "%04ld-%02ld-%02ld", dt->dt_year,
|
||||
dt->dt_month, dt->dt_day);
|
||||
out,
|
||||
NULL,
|
||||
"%04ld-%02ld-%02ld",
|
||||
dt->dt_year,
|
||||
dt->dt_month,
|
||||
dt->dt_day);
|
||||
}
|
||||
|
||||
if (dt->dt_has_date && dt->dt_has_time) {
|
||||
@@ -323,7 +330,11 @@ static enum fx_status encode_rfc3339(const struct fx_datetime_p *dt, fx_stream *
|
||||
|
||||
if (dt->dt_has_time) {
|
||||
fx_stream_write_fmt(
|
||||
out, NULL, "%02ld:%02ld:%02ld", dt->dt_hour, dt->dt_min,
|
||||
out,
|
||||
NULL,
|
||||
"%02ld:%02ld:%02ld",
|
||||
dt->dt_hour,
|
||||
dt->dt_min,
|
||||
dt->dt_sec);
|
||||
|
||||
if (dt->dt_msec > 0) {
|
||||
@@ -336,7 +347,9 @@ static enum fx_status encode_rfc3339(const struct fx_datetime_p *dt, fx_stream *
|
||||
fx_stream_write_char(out, 'Z');
|
||||
} else {
|
||||
fx_stream_write_fmt(
|
||||
out, NULL, "%c%02ld:%02ld",
|
||||
out,
|
||||
NULL,
|
||||
"%c%02ld:%02ld",
|
||||
dt->dt_zone_offset_negative ? '-' : '+',
|
||||
dt->dt_zone_offset_hour,
|
||||
dt->dt_zone_offset_minute);
|
||||
@@ -348,7 +361,9 @@ static enum fx_status encode_rfc3339(const struct fx_datetime_p *dt, fx_stream *
|
||||
}
|
||||
|
||||
static void datetime_to_string(
|
||||
const struct fx_datetime_p *dt, fx_datetime_format format, fx_stream *dest)
|
||||
const struct fx_datetime_p *dt,
|
||||
fx_datetime_format format,
|
||||
fx_stream *dest)
|
||||
{
|
||||
switch (format) {
|
||||
case FX_DATETIME_FORMAT_RFC3339:
|
||||
@@ -453,10 +468,16 @@ fx_datetime *fx_datetime_parse(enum fx_datetime_format format, const char *s)
|
||||
}
|
||||
|
||||
void fx_datetime_to_string(
|
||||
const fx_datetime *dt, fx_datetime_format format, fx_stream *dest)
|
||||
const fx_datetime *dt,
|
||||
fx_datetime_format format,
|
||||
fx_stream *dest)
|
||||
{
|
||||
FX_CLASS_DISPATCH_STATIC(
|
||||
FX_TYPE_DATETIME, datetime_to_string, dt, format, dest);
|
||||
FX_TYPE_DATETIME,
|
||||
datetime_to_string,
|
||||
dt,
|
||||
format,
|
||||
dest);
|
||||
}
|
||||
|
||||
bool fx_datetime_is_localtime(const fx_datetime *dt)
|
||||
@@ -512,17 +533,25 @@ long fx_datetime_subsecond(const fx_datetime *dt)
|
||||
bool fx_datetime_zone_offset_is_negative(const fx_datetime *dt)
|
||||
{
|
||||
FX_CLASS_DISPATCH_STATIC_0(
|
||||
FX_TYPE_DATETIME, datetime_zone_offset_is_negative, dt);
|
||||
FX_TYPE_DATETIME,
|
||||
datetime_zone_offset_is_negative,
|
||||
dt);
|
||||
}
|
||||
|
||||
long fx_datetime_zone_offset_hour(const fx_datetime *dt)
|
||||
{
|
||||
FX_CLASS_DISPATCH_STATIC_0(FX_TYPE_DATETIME, datetime_zone_offset_hour, dt);
|
||||
FX_CLASS_DISPATCH_STATIC_0(
|
||||
FX_TYPE_DATETIME,
|
||||
datetime_zone_offset_hour,
|
||||
dt);
|
||||
}
|
||||
|
||||
long fx_datetime_zone_offset_minute(const fx_datetime *dt)
|
||||
{
|
||||
FX_CLASS_DISPATCH_STATIC_0(FX_TYPE_DATETIME, datetime_zone_offset_minute, dt);
|
||||
FX_CLASS_DISPATCH_STATIC_0(
|
||||
FX_TYPE_DATETIME,
|
||||
datetime_zone_offset_minute,
|
||||
dt);
|
||||
}
|
||||
|
||||
/*** VIRTUAL FUNCTIONS ********************************************************/
|
||||
@@ -543,8 +572,12 @@ static void _datetime_to_string(const fx_object *obj, fx_stream *out)
|
||||
|
||||
if (dt->dt_has_date) {
|
||||
fx_stream_write_fmt(
|
||||
out, NULL, "%04ld-%02ld-%02ld", dt->dt_year,
|
||||
dt->dt_month, dt->dt_day);
|
||||
out,
|
||||
NULL,
|
||||
"%04ld-%02ld-%02ld",
|
||||
dt->dt_year,
|
||||
dt->dt_month,
|
||||
dt->dt_day);
|
||||
}
|
||||
|
||||
if (dt->dt_has_date && dt->dt_has_time) {
|
||||
@@ -553,7 +586,11 @@ static void _datetime_to_string(const fx_object *obj, fx_stream *out)
|
||||
|
||||
if (dt->dt_has_time) {
|
||||
fx_stream_write_fmt(
|
||||
out, NULL, "%02ld:%02ld:%02ld", dt->dt_hour, dt->dt_min,
|
||||
out,
|
||||
NULL,
|
||||
"%02ld:%02ld:%02ld",
|
||||
dt->dt_hour,
|
||||
dt->dt_min,
|
||||
dt->dt_sec);
|
||||
|
||||
if (dt->dt_msec > 0) {
|
||||
@@ -562,7 +599,9 @@ static void _datetime_to_string(const fx_object *obj, fx_stream *out)
|
||||
|
||||
if (!dt->dt_localtime) {
|
||||
fx_stream_write_fmt(
|
||||
out, NULL, " %c%02ld:%02ld",
|
||||
out,
|
||||
NULL,
|
||||
" %c%02ld:%02ld",
|
||||
dt->dt_zone_offset_negative ? '-' : '+',
|
||||
dt->dt_zone_offset_hour,
|
||||
dt->dt_zone_offset_minute);
|
||||
|
||||
Reference in New Issue
Block a user