@@ -23,11 +23,11 @@ #include #import "OFDate.h" #import "OFString.h" #import "OFDictionary.h" -#import "OFNumber.h" +#import "OFXMLElement.h" #import "OFAutoreleasePool.h" #ifdef OF_THREADS # import "OFThread.h" #endif @@ -289,27 +289,36 @@ - (OFString*)description { return [self dateStringWithFormat: @"%Y-%m-%dT%H:%M:%SZ"]; } -- (OFString*)stringBySerializing -{ - OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; - OFDictionary *dictionary = [OFDictionary dictionaryWithKeysAndObjects: - @"seconds", [OFNumber numberWithInt64: seconds], - @"microseconds", [OFNumber numberWithUInt32: microseconds], nil]; - OFString *ret = [[OFString alloc] - initWithFormat: @"(class=OFDate,version=0)<%@>", - [dictionary stringBySerializing]]; - - @try { - [pool release]; - } @finally { - [ret autorelease]; - } - - return ret; +- (OFXMLElement*)XMLElementBySerializing +{ + OFAutoreleasePool *pool; + OFXMLElement *element; + + element = [OFXMLElement elementWithName: @"object" + namespace: OF_SERIALIZATION_NS]; + + pool = [[OFAutoreleasePool alloc] init]; + [element addAttributeWithName: @"class" + stringValue: [self className]]; + + [element addChild: + [OFXMLElement elementWithName: @"seconds" + namespace: OF_SERIALIZATION_NS + stringValue: [OFString stringWithFormat: + @"%" PRId64, seconds]]]; + [element addChild: + [OFXMLElement elementWithName: @"microseconds" + namespace: OF_SERIALIZATION_NS + stringValue: [OFString stringWithFormat: + @"%" PRIu32, microseconds]]]; + + [pool release]; + + return element; } - (uint32_t)microsecond { return microseconds;