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),
Class * _initialize(const ClassDef *def)
Initializes the given Class.
#define alloc(type)
Allocate and initialize and instance of type.
#define super(type, obj, method,...)
struct timeval Time
Time (seconds and microseconds).
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.
Condition * init(Condition *self)
Initializes this Condition.
Data * initWithMemory(Data *self, ident mem, size_t length)
Initializes this Data, taking ownership of the specified memory.
Microsecond-precision immutable dates.
Date * initWithTime(Date *self, const Time *time)
Date * date(void)
Returns a new Date with the current Time.
MutableString * string(void)
Returns a new MutableString.
Object is the root Class of The Objectively Class hierarchy.
Class * _Object(void)
The Object archetype.
char * chars
The backing null-terminated UTF-8 encoded character array.
OBJECTIVELY_EXPORT String * str(const char *fmt,...)
A convenience function for instantiating Strings.