# Please Sir. Can I have some more XML?

Here’s some code I had to write this morning. This isn’t all of it, and it isn’t done yet:

set theTime to the time of theDate
set theHours to theTime / 3600 as integer
set theMinutes to ((theTime mod 3600) / 60) as integer
set theSeconds to theTime mod 60
if (theSeconds &lt; 10) then
set theSeconds to "0" & theSeconds
end if
if (theMinutes &lt; 10) then
set theMinutes to "0" & theMinutes
end if
if (theHours &lt; 10) then
set theHours to "0" & theHours
end if

set atomdate to atomdate & "T" & theHours & ":" & theMinutes & ":" & theSeconds & "Z"

The reason I need to do this is because I’m working with a tool that “helpfully” converts Atom and RSS feeds into a date object. Only it happens that the particular date class in this environment won’t format a date in ISO 8601 style as required by Atom, so when I put the date back into another Atom feed I have to rebuild the entire date by hand. If I had the real XML available I could just copy the original date, It would be about a thousand times simpler and less buggy and less likely to break.

Moral of the story: don’t “help” users out by changing XML into something else, especially not objects. Don’t assume you know what they’re going to want to do with the data. Give them the XML and let them use the classes and objects that fit their needs, not the ones that fit your needs. XML is exchangeable. Objects are not.