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

Use default TZ when calculating birthdate if on_date param is not set #112

Merged
merged 2 commits into from
Aug 19, 2024

Conversation

xispa
Copy link
Member

@xispa xispa commented Aug 19, 2024

Description of the issue/feature this PR addresses

This Pull Request makes the system to use system's default Timezone when calculating the date of birth via api.get_birth_date if no value for parameter on_date is explicitly set.

As a result, this fixes the following test:
https://github.com/senaite/senaite.patient/actions/runs/10426342600/job/28879098625#step:7:226

Current behavior before PR

System does not take system's default TZ when calculating birthdate if on_date is not set

Desired behavior after PR is merged

System does take system's default TZ when calculating birthdate if on_date is not set

--
I confirm I have tested this PR thoroughly and coded it according to PEP8
and Plone's Python styleguide standards.

@xispa xispa changed the title Use default TZ when calculating birthdate without on_date parameter explicitly set Use default TZ when calculating birthdate if on_date param is not set Aug 19, 2024
@xispa xispa requested a review from ramonski August 19, 2024 10:20
@xispa xispa added the bug Something isn't working label Aug 19, 2024
Copy link
Contributor

@ramonski ramonski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! And indeed, the TZ settings are challenging.
Maybe we should always use instead the TZ of the current logged in user in the future, which you can configure in the User Profile...

@ramonski ramonski merged commit 6413cc1 into master Aug 19, 2024
2 checks passed
@ramonski ramonski deleted the fix-agedob-field-test branch August 19, 2024 10:49
@xispa
Copy link
Member Author

xispa commented Aug 19, 2024

Thanks! And indeed, the TZ settings are challenging. Maybe we should always use instead the TZ of the current logged in user in the future, which you can configure in the User Profile...

Yes fully agree.

For the records, there is the function plone.app.event.base.default_timezone that can be used to get the user's TZ (and fallback to site's default as well). I think is worth to add a kind-of shortcut function senaite.core.api.dtime.get_user_timezone(user=None) like we have for os (senaite.core.api.dtime.get_os_timezone). Or even a get_default_timezone() that relies on get_user_timezone and fallsback to get_os_timezone if not a valid TZ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging this pull request may close these issues.

2 participants