ds: datetime: convert to new object system

This commit is contained in:
2025-10-19 11:25:15 +01:00
parent dacbc5e9c2
commit b3de59ae24
3 changed files with 188 additions and 102 deletions

View File

@@ -1,34 +1,31 @@
#ifndef BLUELIB_DATETIME_H_
#define BLUELIB_DATETIME_H_
#ifndef BLUE_DS_DATETIME_H_
#define BLUE_DS_DATETIME_H_
#include <blue/core/macros.h>
#include <blue/core/status.h>
#include <blue/ds/object.h>
#include <blue/ds/type.h>
#include <ctype.h>
struct b_string;
B_DECLS_BEGIN;
#define B_DATETIME(p) ((b_datetime *)(p))
#define B_TYPE_DATETIME (b_datetime_get_type())
typedef struct b_datetime b_datetime;
B_DECLARE_TYPE(b_datetime);
B_TYPE_CLASS_DECLARATION_BEGIN(b_datetime)
B_TYPE_CLASS_DECLARATION_END(b_datetime)
typedef enum b_datetime_format {
B_DATETIME_FORMAT_RFC3339 = 1,
} b_datetime_format;
BLUE_API b_datetime *b_datetime_create(void);
BLUE_API b_type b_datetime_get_type(void);
B_TYPE_DEFAULT_CONSTRUCTOR(b_datetime, B_TYPE_DATETIME);
BLUE_API b_datetime *b_datetime_parse(b_datetime_format format, const char *s);
BLUE_API void b_datetime_to_string(
const b_datetime *dt, b_datetime_format format, struct b_string *dest);
static inline b_datetime *b_datetime_retain(b_datetime *dt)
{
return B_DATETIME(b_retain(B_DSREF(dt)));
}
static inline void b_datetime_release(b_datetime *dt)
{
b_release(B_DSREF(dt));
}
const b_datetime *dt, b_datetime_format format,
B_TYPE_FWDREF(b_string) * dest);
BLUE_API bool b_datetime_is_localtime(const b_datetime *dt);
BLUE_API bool b_datetime_has_date(const b_datetime *dt);
@@ -46,4 +43,6 @@ BLUE_API bool b_datetime_zone_offset_is_negative(const b_datetime *dt);
BLUE_API long b_datetime_zone_offset_hour(const b_datetime *dt);
BLUE_API long b_datetime_zone_offset_minute(const b_datetime *dt);
B_DECLS_END;
#endif