Skip to content

Conversation

@Sreevarsh-Mahesh
Copy link

@Sreevarsh-Mahesh Sreevarsh-Mahesh commented Dec 3, 2025

Summary

This PR adds support for string datetime inputs to the get_localized_time() helper function.

Changes

  • Updated get_localized_time() docstring to document string input support
  • Fixed incorrect parameter description (was "Message to show", now correctly "Date/time to display")
  • Updated type annotation to include string as a valid input type
  • Added comprehensive test case test_get_localized_time_string() with multiple string format scenarios

Details

The underlying ulocalized_time() method in plone.base already handles string-to-DateTime conversion (via the DateTime constructor), so no actual code logic changes were needed - only documentation updates to make this capability clear to users.

Tests

Added test_get_localized_time_string() which tests:

  • ISO 8601 datetime strings with long_format=True
  • ISO 8601 datetime strings with time_only=True
  • ISO 8601 datetime strings with default format
  • Date-only strings

Fixes #593


📚 Documentation preview 📚: https://ploneapi--595.org.readthedocs.build/

- Updated docstring to document string input support
- Fixed incorrect param description (was 'Message to show', now 'Date/time to display')
- Updated type annotation to include string
- Added test_get_localized_time_string() test case
- Tests various string datetime formats (ISO 8601)

Fixes plone#593
Copilot AI review requested due to automatic review settings December 3, 2025 22:30
@mister-roboto
Copy link

@Sreevarsh-Mahesh you need to sign the Plone Contributor Agreement to merge this pull request.

Learn about the Plone Contributor Agreement: https://plone.org/foundation/contributors-agreement

If you have already signed the agreement, please allow a week for your agreement to be processed.
Once it is processed, you will receive an email invitation to join the plone GitHub organization as a Contributor.

If after a week you have not received an invitation, then please contact [email protected].

@mister-roboto
Copy link

@Sreevarsh-Mahesh thanks for creating this Pull Request and helping to improve Plone!

TL;DR: Finish pushing changes, pass all other checks, then paste a comment:

@jenkins-plone-org please run jobs

To ensure that these changes do not break other parts of Plone, the Plone test suite matrix needs to pass, but it takes 30-60 min. Other CI checks are usually much faster and the Plone Jenkins resources are limited, so when done pushing changes and all other checks pass either start all Jenkins PR jobs yourself, or simply add the comment above in this PR to start all the jobs automatically.

Happy hacking!

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for string datetime inputs to the get_localized_time() helper function by documenting its existing capability to accept string inputs. The underlying ulocalized_time() method in plone.base already handles string-to-DateTime conversion, so only documentation and test updates were needed.

  • Updated docstring to clarify that string inputs are accepted and how they are processed
  • Fixed parameter description from "Message to show" to "Date/time to display"
  • Added comprehensive test coverage for string datetime inputs

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/plone/api/portal.py Updated get_localized_time() docstring to document string input support and corrected parameter description
src/plone/api/tests/test_portal.py Added test_get_localized_time_string() method testing ISO 8601 datetime strings, date-only strings, and various format options

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@stevepiercy
Copy link
Contributor

@Sreevarsh-Mahesh
Copy link
Author

Hi @stevepiercy, thank you for the guidance.

I apologize for not following the proper procedure outlined in the First-time contributors guide. I have now signed the Plone Contributor Agreement and am waiting for the invitation to join the Contributors Team.

I will close this PR for now. Once I receive and accept the invitation, I will:

  1. Confirm this issue isn't claimed or resolved or being worked on.
  2. Add the required changelog fragment in the news/ directory
  3. Run tests locally to ensure everything passes
  4. Resubmit the PR following the proper workflow

Thank you for your patience as I learn the contribution process!

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

Successfully merging this pull request may close these issues.

The helper get_localized_time should also accept string

3 participants