> I'm looking at the XML store file, and the date format is confusing. I
> thought it would be base-64 encoded NSDate in iso 8601. There's something
> else going on. The content of the attribute seems to vary with the
> formatter
> used with the attribute, which is odd. Why not store in one flavor?
Thank you !
> > I'm looking at the XML store file, and the date format is confusing. I
>> thought it would be base-64 encoded NSDate in iso 8601. There's something
>> else going on. The content of the attribute seems to vary with the formatter
>> used with the attribute, which is odd. Why not store in one flavor?
> Do you really see different formats within the same XML file?
Not within the same file, per se. I changed formatters, and the content
changed dramatically.
It's possible it could be an aberration, since I didn't actually
document specific dates'
content, but it certainly looked different. I can take a closer look
> I only encountered this issue when dealing with a parser for XML and
> binary plists.
[quoted text clipped - 4 lines]
> look at CFAbsoluteTime;
> http://developer.apple.com/documentation/CoreFoundation/Conceptual/CFDatesAndTim
es/index.html).
Okay,
it certainly _looks_ like a relative seconds thing; deltas between
consecutive days
are the number of seconds in a day, so that settles that. Negative
numbers and all for older
dates.
So are we to assume that the XML store uses this standard, and not ISO
8601 as I've
been lead to believe? All the googling I've done says it's 8601.
> Hope this helps.
>
> CU,
>
> Udo
Udo Schneider - 28 Jul 2005 07:49 GMT
> Not within the same file, per se. I changed formatters, and the content
> changed dramatically.
> It's possible it could be an aberration, since I didn't actually
> document specific dates'
> content, but it certainly looked different. I can take a closer look
Could you give an example?
> it certainly _looks_ like a relative seconds thing; deltas between
> consecutive days
> are the number of seconds in a day, so that settles that. Negative
> numbers and all for older
> dates.
According to CF-368.11\NumberDate.subproj\CFDate.h CFAbsoluteTime is
indeed a second offset:
[...]
typedef double CFTimeInterval;
typedef CFTimeInterval CFAbsoluteTime;
/* absolute time is the time interval since the reference date */
/* the reference date (epoch) is 00:00:00 1 January 2001. */
[...]
This is also confirmed if you take a lookt how an CFAbsoluteTime is
obtained in CF-368.11\NumberDate.subproj\CFDate.c:
[...]
CFAbsoluteTime CFAbsoluteTimeGetCurrent(void) {
CFAbsoluteTime ret;
#if defined(__MACH__) || defined(__svr4__) || defined(__hpux__) ||
defined(__LINUX__)
struct timeval tv;
gettimeofday(&tv, NULL);
ret = (CFTimeInterval)tv.tv_sec - kCFAbsoluteTimeIntervalSince1970;
ret += (1.0E-6 * (CFTimeInterval)tv.tv_usec);
#elif defined(__WIN32__)
FILETIME ft;
GetSystemTimeAsFileTime(&ft);
ret = _CFAbsoluteTimeFromFileTime(&ft);
#else
#error CFAbsoluteTimeGetCurrent unimplemented for this platform
#endif
return ret;
}
[...]
> So are we to assume that the XML store uses this standard, and not ISO
> 8601 as I've
> been lead to believe? All the googling I've done says it's 8601.
We both were right. I just doublechecked ("[...] read the source Luke!")
and found this (in CF-368.11/PropertyList.dtd):
<!ELEMENT date (#PCDATA)> <!-- Contents should conform to a subset of
ISO 8601 (in particular, YYYY '-' MM '-' DD 'T' HH ':' MM ':' SS 'Z'.
Smaller units may be omitted with a loss of precision) -->
This is of course ISO 8601 (although "just" a subset) .... but also
perfetcly valid RFC3339 (subset as well).
This subset avoids all the subtle details of ISO8601/RFC3339 (fractional
milliseconds ... ) .... but will allow me to use a much simpler parser
than my full blown RFC3339 parser :-).
CU,
Udo