122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
#ifdef HAVE_GMTIME_R
struct tm tm;
if (gmtime_r(&sec, &tm) == NULL)
@throw [OFOutOfRangeException newWithClass: isa];
strftime(str, 20, "%Y-%m-%d %H:%M:%S", &tm);
#else
struct tm *tm;
# ifdef OF_THREADS
[mutex lock];
@try {
# endif
if ((tm = gmtime(&sec)) == NULL)
@throw [OFOutOfRangeException newWithClass: isa];
strftime(str, 20, "%Y-%m-%d %H:%M:%S", tm);
# ifdef OF_THREADS
} @finally {
[mutex unlock];
}
# endif
#endif
if (usec == 0)
return [OFString stringWithFormat: @"%sZ", str];
return [OFString stringWithFormat: @"%s.%06dZ", str, usec];
}
@end
|
|
|
|
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
#ifdef HAVE_GMTIME_R
struct tm tm;
if (gmtime_r(&sec, &tm) == NULL)
@throw [OFOutOfRangeException newWithClass: isa];
strftime(str, 20, "%Y-%m-%dT%H:%M:%S", &tm);
#else
struct tm *tm;
# ifdef OF_THREADS
[mutex lock];
@try {
# endif
if ((tm = gmtime(&sec)) == NULL)
@throw [OFOutOfRangeException newWithClass: isa];
strftime(str, 20, "%Y-%m-%dT%H:%M:%S", tm);
# ifdef OF_THREADS
} @finally {
[mutex unlock];
}
# endif
#endif
if (usec == 0)
return [OFString stringWithFormat: @"%sZ", str];
return [OFString stringWithFormat: @"%s.%06dZ", str, usec];
}
@end
|