mirror of
https://github.com/gnustep/libs-base.git
synced 2025-06-01 09:02:01 +00:00
Improve date handling in text representation of property list.
Make XML format consistent with MacOS-X git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@19908 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
d3f69e8740
commit
2ef86a582f
2 changed files with 26 additions and 6 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2004-08-24 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Source/NSPropertyList.m: Always write date using GMT timezone for
|
||||||
|
consistency. Make XML representation MacOS-X compatible.
|
||||||
|
|
||||||
2004-08-23 Richard Frith-Macdonald <rfm@gnu.org>
|
2004-08-23 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/Additions/GSMime.m: Add content location methods.
|
* Source/Additions/GSMime.m: Add content location methods.
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
#include "Foundation/NSPropertyList.h"
|
#include "Foundation/NSPropertyList.h"
|
||||||
#include "Foundation/NSSerialization.h"
|
#include "Foundation/NSSerialization.h"
|
||||||
#include "Foundation/NSString.h"
|
#include "Foundation/NSString.h"
|
||||||
|
#include "Foundation/NSTimeZone.h"
|
||||||
#include "Foundation/NSUserDefaults.h"
|
#include "Foundation/NSUserDefaults.h"
|
||||||
#include "Foundation/NSValue.h"
|
#include "Foundation/NSValue.h"
|
||||||
#include "Foundation/NSDebug.h"
|
#include "Foundation/NSDebug.h"
|
||||||
|
@ -962,8 +963,16 @@ nodeToObject(GSXMLNode* node, NSPropertyListMutabilityOptions o, NSString **e)
|
||||||
{
|
{
|
||||||
content = @"";
|
content = @"";
|
||||||
}
|
}
|
||||||
result = [NSCalendarDate dateWithString: content
|
if ([content hasSuffix: @"Z"] == YES && [content length] == 20)
|
||||||
calendarFormat: @"%Y-%m-%d %H:%M:%S %z"];
|
{
|
||||||
|
result = [NSCalendarDate dateWithString: content
|
||||||
|
calendarFormat: @"%Y-%m-%dT%H:%M:%SZ"];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = [NSCalendarDate dateWithString: content
|
||||||
|
calendarFormat: @"%Y-%m-%d %H:%M:%S %z"];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if ([name isEqualToString: @"data"])
|
else if ([name isEqualToString: @"data"])
|
||||||
{
|
{
|
||||||
|
@ -1653,11 +1662,17 @@ OAppend(id obj, NSDictionary *loc, unsigned lev, unsigned step,
|
||||||
}
|
}
|
||||||
else if ([obj isKindOfClass: [NSDate class]])
|
else if ([obj isKindOfClass: [NSDate class]])
|
||||||
{
|
{
|
||||||
|
static NSTimeZone *z = nil;
|
||||||
|
|
||||||
|
if (z == nil)
|
||||||
|
{
|
||||||
|
z = RETAIN([NSTimeZone timeZoneForSecondsFromGMT: 0]);
|
||||||
|
}
|
||||||
if (x == NSPropertyListXMLFormat_v1_0)
|
if (x == NSPropertyListXMLFormat_v1_0)
|
||||||
{
|
{
|
||||||
[dest appendBytes: "<date>" length: 6];
|
[dest appendBytes: "<date>" length: 6];
|
||||||
obj = [obj descriptionWithCalendarFormat: @"%Y-%m-%d %H:%M:%S %z"
|
obj = [obj descriptionWithCalendarFormat: @"%Y-%m-%dT%H:%M:%SZ"
|
||||||
timeZone: nil locale: nil];
|
timeZone: z locale: nil];
|
||||||
obj = [obj dataUsingEncoding: NSASCIIStringEncoding];
|
obj = [obj dataUsingEncoding: NSASCIIStringEncoding];
|
||||||
[dest appendData: obj];
|
[dest appendData: obj];
|
||||||
[dest appendBytes: "</date>\n" length: 8];
|
[dest appendBytes: "</date>\n" length: 8];
|
||||||
|
@ -1666,7 +1681,7 @@ OAppend(id obj, NSDictionary *loc, unsigned lev, unsigned step,
|
||||||
{
|
{
|
||||||
[dest appendBytes: "<*D" length: 3];
|
[dest appendBytes: "<*D" length: 3];
|
||||||
obj = [obj descriptionWithCalendarFormat: @"%Y-%m-%d %H:%M:%S %z"
|
obj = [obj descriptionWithCalendarFormat: @"%Y-%m-%d %H:%M:%S %z"
|
||||||
timeZone: nil locale: nil];
|
timeZone: z locale: nil];
|
||||||
obj = [obj dataUsingEncoding: NSASCIIStringEncoding];
|
obj = [obj dataUsingEncoding: NSASCIIStringEncoding];
|
||||||
[dest appendData: obj];
|
[dest appendData: obj];
|
||||||
[dest appendBytes: ">" length: 1];
|
[dest appendBytes: ">" length: 1];
|
||||||
|
@ -1674,7 +1689,7 @@ OAppend(id obj, NSDictionary *loc, unsigned lev, unsigned step,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
obj = [obj descriptionWithCalendarFormat: @"%Y-%m-%d %H:%M:%S %z"
|
obj = [obj descriptionWithCalendarFormat: @"%Y-%m-%d %H:%M:%S %z"
|
||||||
timeZone: nil locale: nil];
|
timeZone: z locale: nil];
|
||||||
PString(obj, dest);
|
PString(obj, dest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue