-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preserve timezone when converting DateTime to OFX. #115
Conversation
This is a mechanical search and replace in preparation for the next commit which changes the formatting used for the UTC timezone.
Some OFX servers are particular about the formatting of the timezone in `<DTSTART>` elements, and they reject the `[0:GMT]` timezone produced by ofxtools. Preserve the timezone of the `datetime` objects used when generating the OFX timestamps to avoid this problem. Always format the UTX offset with a leading `+` or `-`, even though the OFX spec permits the `+` to be dropped. Move the timestamp formatting into a `format_datetime()` which is shared by the `DateTime` and `Time` classes. This also ensures that millisecond rounding is handled correctly for both.
Updated the PR with some tests, and also shared the formatting code with the Some timezones in Australia and India have a fractional hour offset from UTC. The OFX 1.6 standard says:
I interpret this as a decimal fraction, so India's +0530 offset becomes I don't know if OFX is used in India or Australia. |
I don't think the OFX spec writers were precise enough with their language that their choice of the word "fraction" should outweigh the huge driving force to fall in line with ISO 8601 conventions. The OFXv1 DTDs (SGML doc definitions) are sloppy, but the date & time regexes in Don't worry about it though, usage of OFX outside of America is low. I'll fix this part. Thanks very much for fixing up the tests, it's appreciated. |
Yeah, I agree. Decimal fractions would be silly. I pushed an updated version at https://github.com/stoklund/ofxtools/tree/timezone which uses minutes. |
I was just sitting down to overhaul that old logic to use datetime division... thanks for doing it. A lot of code in this module dates back to the days of Python 2. Now that we're requiring recent versions of Python, I guess we can now employ f-strings too! |
Done in 8bee7fe Thanks again. |
Some OFX servers are particular about the formatting of the timezone in
<DTSTART>
elements, and they reject the[0:GMT]
timezone produced byofxtools.
Preserve the timezone of the
datetime
objects used when generating the OFXtimestamps to avoid this problem.
See discussion in #114.