Adding a timezone into XML?

Quarthinos

Ars Praefectus
3,150
Subscriptor
So our input format has changed. They used to include the timezone in the timestamps using the standard -04:00/-05:00 after HH:mm:SS.sss. But they've updated the record generation to be "in the cloud!", and it looks like they found some random intern who just vibe coded it. There's also several fields that used to be empty, but are now just not being included.

I've been able to generate the missing fields via some xslt magic copypasta'd from StackExchange (with edits of course), but the machines I'm using are all on GMT, so I can't rely on the local clock to figure out the correct timezone offset. Other than creating two xslt, one for each of -04:00 and -05:00 and then relying on the date at the receiver to figure out how the generator should have encoded the timestamp (which ignores transmission time, which is non-trivial), anyone else have any ideas? The other possibility is to spin up an IDE and fix the process that's throwing null pointers from all the missing data, but we're in an isolated environment and all the supporting libraries have been moved to different repos in an undocumented way since the process was last compiled, before COVID, and the VM with the source doesn't seem to have an IDE any more. And that wouldn't fix the missing timezone, it would just be ignored or hardcoded a different way.
 

fitten

Ars Legatus Legionis
55,631
Subscriptor++
First, you should have an XSD data contract with all your inputs and your outputs so that it doesn't pass the check before they even send it to you and then they have to fix it on their end. It seems you don't have this now so maybe this is something that can be done going forward.

Second, if you are able, push this up your chain. Depending on your business, the lack of timezone in the data may be an Issue™ due to uncertainty in the data. This is a breaking change in your input. While you may need to deal with data as you have it and can't force them to resend with proper time data, you can try to fix the problem at its source and have them send you the proper/correct data. Until then, it would depend on the volume of your data... is it one file per day or hundreds per hour? How'd you'd fix it while the source puts in a fix will be different... once per day you can fix it by hand, lots per day you need an automated way.

As far as an automated way, I assume you have some way of knowing from which timezone the input comes from... you'll probably just have to set up a way to run your input through the XSLT before ingestion into the rest of your process. Is there a way to 'fake out' your processes by getting the input from a middleman you put in to do the XSLT before handing over to the process?
 
Last edited:

Quarthinos

Ars Praefectus
3,150
Subscriptor
We check for xsd compliance very first thing. It's just that the xsd specifies a timestamp, but not that it must include a timezone* (not even sure if that's possible with out of the box xsd?) We are in the process of talking to the data producers about fixing it, but I'm looking for some way to fix it if it ever happens again, hopefully without having to change it twice a year as daylight time turns on and off.

We've already just fixed the thousands of records from today with a hardcoded -04:00 (or maybe 5, I can't be bothered to look in the isolated environment). I'm partially venting, but also curious as to what's possible with xslt at the edge. I know it exists and use it where I can, but doing complex logic inside xslt 1.0 is not something I need to do more than once a decade.

*This is probably why (what I assume is) the vibe coded quick solution they came up with to put it in the cloud is breaking my code after more than five years of smooth sailing. And the end users will start screaming soon if this isn't fixed, but that's between their management entities, most of whom aren't even aware of my tooling.


edit: The xsd is specified in an ICD under control of the people who are generating the data, and they're technically compliant.
 

fitten

Ars Legatus Legionis
55,631
Subscriptor++
We check for xsd compliance very first thing. It's just that the xsd specifies a timestamp, but not that it must include a timezone* (not even sure if that's possible with out of the box xsd?) We are in the process of talking to the data producers about fixing it, but I'm looking for some way to fix it if it ever happens again, hopefully without having to change it twice a year as daylight time turns on and off.

edit: The xsd is specified in an ICD under control of the people who are generating the data, and they're technically compliant.


Just as an aside, it sounds like you've found a flaw in the data contract and it needs mending. Timezones are a vital part of a timestamp.


As far as fixing the data, if you are importing this to a database, perhaps you can set up a process that runs an UPDATE query once per day to fix the date in the records. It may be a more complex query in that it may have to be able to determine per-record where the data came from and adjusting/assigning the date appropriately. Maybe there is another date or datetime field present where you can at least get the right hhmmss and then determine the timezone and fix appropriately?

Ultimately, though, I would seriously try to fix the input data so this cleanup doesn't have to keep happening. Once the input is fixed, you can remove the kludge UPDATE. Stress that this is a temporary workaround for a problem with the input data that must be resolved.
 

Quarthinos

Ars Praefectus
3,150
Subscriptor
Just as an aside, it sounds like you've found a flaw in the data contract and it needs mending. Timezones are a vital part of a timestamp.
It'd be nice if I had any power to alter the ICD, but it's been in place since before 2018 and never been modified. Given the data, I wouldn't be surprised if the ICD is referenced in various international treaty documents. The data starts in a database (at least in a vague sense, not sure if it's Oracle or Access or just a random collection of files), and then is exported into a portable format (as specified by the ICD and its included xsd) so other people can use it. I've spoken to some of the people who have worked in that particular sausage factory off the record, and it's a Frankenstein's Monster of bailing wire and kludge. They just moved the export tooling to the cloud and when it hit our servers it immediately didn't work. No idea if the other consumers (assuming they exist) have said anything. Given what's been happening in the current administration and the amount of money going around, I still think the cloud converter was written by some agentic AI put together by someone who got their BS (in a computer-related field if I'm lucky) earlier this year, so they don't understand how important the timezone is. I mean it's just Eastern Standard Time, right? How hard can it be?