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

Feature: add option to set default timezone #142

Merged
merged 8 commits into from
Oct 7, 2022
Merged

Conversation

Guts
Copy link
Owner

@Guts Guts commented Oct 4, 2022

Example:

- rss:
    date_from_meta:
      as_creation: "date"
      as_update: false
      datetime_format: "%Y-%m-%d %H:%M"
      default_timezone: "Europe/Paris"

Defaults to UTC.

  • Python >= 3.9 - no need for additional 3rd party package (or tzdata if an updated version of IANA db is needed)
  • Python < 3.9 - need to install pytz alongside.

Closes #133

@Guts Guts added the enhancement New feature or request label Oct 4, 2022
@Guts Guts self-assigned this Oct 4, 2022
@github-actions github-actions bot added the documentation Improvements or additions to documentation label Oct 4, 2022
@codecov
Copy link

codecov bot commented Oct 4, 2022

Codecov Report

Merging #142 (4083099) into main (9dc0f24) will increase coverage by 0.48%.
The diff coverage is 87.50%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #142      +/-   ##
==========================================
+ Coverage   81.21%   81.69%   +0.48%     
==========================================
  Files           5        7       +2     
  Lines         330      366      +36     
  Branches       72       80       +8     
==========================================
+ Hits          268      299      +31     
- Misses         40       42       +2     
- Partials       22       25       +3     
Impacted Files Coverage Δ
mkdocs_rss_plugin/timezoner_pre39.py 83.33% <83.33%> (ø)
mkdocs_rss_plugin/timezoner_py39.py 83.33% <83.33%> (ø)
mkdocs_rss_plugin/util.py 72.43% <92.85%> (+1.00%) ⬆️
mkdocs_rss_plugin/plugin.py 96.15% <100.00%> (+0.07%) ⬆️

@Guts Guts marked this pull request as ready for review October 7, 2022 08:51
@Guts Guts merged commit 33d1a1a into main Oct 7, 2022
@Guts Guts deleted the feature/default-timezone branch October 7, 2022 08:52
@squidfunk
Copy link

Awesome, thanks for implementing! Looking forward to the next release (no hurry) 😀

@Guts
Copy link
Owner Author

Guts commented Oct 7, 2022

Awesome, thanks for implementing! Looking forward to the next release (no hurry) grinning

Thanks for testing and feeding back. I wanted to complete the related documentation before releasing.

It leads me to think about a default_time option allowing to set a default hour of publication to avoid the "midnight syndrome". With a range to get a random hour picked?

What do you think @squidfunk?

@Guts
Copy link
Owner Author

Guts commented Oct 7, 2022

It leads me to think about a default_time option allowing to set a default hour of publication to avoid the "midnight syndrome".

Got time to implement it in #145

@squidfunk
Copy link

It leads me to think about a default_time option allowing to set a default hour of publication to avoid the "midnight syndrome". With a range to get a random hour picked?

Shouldn't that be covered by UTC? The idea was that if you parse the date, it should default to YYYY-mm-dd 00:00:00.

@Guts
Copy link
Owner Author

Guts commented Oct 8, 2022

It's defined before to set the timezone (custom or UTC by default), so the time is just added to a simple date. Example:

Config:

plugins:
  - rss:
      date_from_meta:
        as_creation: "date"
        as_update: false
        datetime_format: "%Y-%m-%d"
        default_time: "22:00"

Page meta:

---
title: "This page title is a perfect clickbait!"
authors:
  - guts
date: 2020-10-22
---

Output:

  <pubDate>Thu, 22 Oct 2020 22:00:00 +0000</pubDate>

Am I missing something?

@squidfunk
Copy link

Okay, I may have confused something here. My problem was that when the date is left out, the time was shifted by the timezone offset. Since this is fixed now, you can view my comment as resolved. Personally, I don't see much use for a default_time option, but when you think it makes sense, I see no problem with this conflicting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Date shifted by timezone when using date_from_meta
2 participants