Skip to content
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

DateTime UTC and local mismatch #259

Open
Siderite opened this issue Oct 2, 2019 · 1 comment
Open

DateTime UTC and local mismatch #259

Siderite opened this issue Oct 2, 2019 · 1 comment

Comments

@Siderite
Copy link

Siderite commented Oct 2, 2019

In controllers, in order to display posts, the PubDate of posts is compared with DateTime.UtcNow, only the datetime of the posts is local, even if retrieved from a UTC formatted string. It should be
post.PubDate <= DateTime.Now or post.PubDate.ToUniversalTime() <= DateTime.UtcNow

@Siderite
Copy link
Author

Siderite commented Oct 2, 2019

Actually, my solution was to load all dates from XML as universal time, as it is proper, so the code in the controllers would continue to work as expected. So PubDate = DateTime.Parse(ReadValue(entry, "published")).ToUniversalTime() and so on. But then I had an issue with the display of the date, so I've added a span around the displayed time then added jQuery code to read the time datetime attribute, parse it, then display it in local time. I've also changed the DateTime.ToString parameter for rendering the datetime attribute to "o" from "s".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant