32#define _Class _DateFormatter
34#pragma mark - DateFormatter
43 fprintf(stderr,
"WARNING: %s: not implemented (Windows)\n", __func__);
48 const char *res = strptime(chars, self->
fmt, &time);
50 const Time t = { .tv_sec = mktime(&time) };
92 const time_t seconds =
date->
time.tv_sec;
96 int err = localtime_s(&time, &seconds);
99 ident res = localtime_r(&seconds, &time);
100 assert(res == &time);
103 char *
str = calloc(1024,
sizeof(
char));
106 const size_t length = strftime(
str, 1024, self->
fmt, &time);
107 str = realloc(
str, length + 1 *
sizeof(
char));
113#pragma mark - Class lifecycle
138 .name =
"DateFormatter",
142 .interfaceSize =
sizeof(DateFormatterInterface),
static Array * init(Array *self)
Class * _initialize(const ClassDef *def)
Initializes the given Class.
#define alloc(type)
Allocate and initialize and instance of type.
#define super(type, obj, method,...)
static Data * initWithMemory(Data *self, ident mem, size_t length)
static Date * initWithTime(Date *self, const Time *time)
struct timeval Time
Time (seconds and microseconds).
static String * string(void)
String * str(const char *fmt,...)
void * ident
The identity type, similar to Objective-C id.
#define do_once(once, block)
Executes the given block at most one time.
ClassDefs are passed to _initialize via an archetype to initialize a Class.
The runtime representation of a Class.
ident interface
The interface of the Class.
Microsecond-precision immutable dates.
Object is the root Class of The Objectively Class hierarchy.
char * chars
The backing null-terminated UTF-8 encoded character array.