Closed sureshjoshi closed 3 years ago
No idea! That's interesting, though. I haven't looked closely at how (or if) YAML parses and stringifies dates, but that's where I'd start.
Glad you like the library.
Going to chalk this up to YAML's idiosyncrasies. Closing pending further complications.
It is unfortunate that the timezone information is lost. This is not just a cosmetic formatting issue but an unexpected data conversion.
It's super weird, because I've done some line by line copying of parts of each project - and the result is a DT string with timezone. So, must be something in the glue code.
Having said that, I also haven't tried using the same example files in a long time - because for my case, I really don't care about timezone. Even more, I only care about the date (+/- 1 day)
I just ran this code and the result looks correct: https://gist.github.com/eyeseast/28a2df48a67921bba660ef8396088d54
import frontmatter
text = """
---
date: 2012-10-11T23:39:45-04:00
---
Content
"""
post = frontmatter.loads(text)
print(frontmatter.dumps(post))
Output:
---
date: 2012-10-11 23:39:45-04:00
---
Content
So the date formatting changed, but not in a way I'd call incorrect. I ran this on Python 3.9.4.
I'm happy to reopen this if someone can reproduce the issue. It's definitely a bug if timezones are getting dropped.
I'm very confused about the following behavior:
text = """
---
wake_up: 06:20
sleep: 10:00
---
Content
"""
post = frontmatter.loads(text)
print(frontmatter.dumps(post))
Result:
---
sleep: 600
wake_up: 06:20
---
Content
sleep
is changed completely (but not wake_up
). The sleep
value is changed from 10:00
to 600
.
Config: OS: Linux Python: 3.10.4 python-frontmatter: 1.0.0
Any idea is much appreciated. Thanks!
I tried the js's parser Markdown YAML metadata parser and got the same result. I think I got the YAML format wrong. I quoted the value "10:00" and got the same result back. Thanks!
Just started using python-frontmatter, and it's great. It allowed me to switch away from some cobbled together code to something much cleaner - and I'm able to comfortably release knowing I can adjust front-matter as it suits me. Kudos! Though, I did have a question that I have no strong opinions on.
Why are my dates modified automatically from ISO8601? For this project, it doesn't really matter - but it's strange that it happens at all.
becomes