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

Suggest an ISO 8601 sample in datetime.set_value #101609

Merged

Conversation

2franix
Copy link
Contributor

@2franix 2franix commented Oct 7, 2023

Proposed change

The example datetime value proposed in the developer tools for the datetime.set_value is currently not correct. It does not comply with any of the formats supported by parse_datetime() in homeassistant/util/dt.py

image

The obvious problem is the slashes in the date which must be replaced by hyphens. So we could just use 2022-11-01 22:15 and that would work.

But parse_datetime() does its first parsing attempt against the ISO 8601 format and the regex looks like a fallback approach to me. Because of that, I figured proposing a value complying with the ISO standard is the best we can do to educate users as to how to use the datetime.set_value service.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: No issue submitted yet. I'm happy to file one if needed!
  • This PR is related to issue:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

The example datetime value proposed in the developer tools for the datetime.set_value is currently not correct. It does not comply with any of the formats supported by [`parse_datetime()`](https://github.com/home-assistant/core/blob/55bf309d2f9b5bde2025fbae9f0d101b8755893b/homeassistant/util/dt.py#L183) in `homeassistant/util/dt.py`

The problem is the slashes in the date which must be replaced by hyphens.

But this function does its first parsing attempt against the ISO 8601 format. The regex looks like a fallback approach to me. And I figured proposing a value complying with the ISO standard is the best we can do to educate users as to how to use the datetime.set_value service.
@2franix 2franix requested a review from a team as a code owner October 7, 2023 20:05
Copy link

@home-assistant home-assistant bot left a comment

Choose a reason for hiding this comment

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

Hi @2franix

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@home-assistant
Copy link

home-assistant bot commented Oct 7, 2023

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@home-assistant
Copy link

home-assistant bot commented Oct 7, 2023

Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration (datetime) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of datetime can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign datetime Removes the current integration label and assignees on the pull request, add the integration domain after the command.

@home-assistant home-assistant bot marked this pull request as draft October 8, 2023 04:39
@2franix 2franix marked this pull request as ready for review October 8, 2023 07:08
Copy link
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

Thanks!

@MartinHjelmare
Copy link
Member

Please don't touch the branch after approval unless requested. Thanks!

@2franix
Copy link
Contributor Author

2franix commented Oct 8, 2023

Sorry, my bad. I was confused regarding the next steps and I hit the update branch button by mistake.

@2franix
Copy link
Contributor Author

2franix commented Oct 8, 2023

Just curious: how do you guarantee not to break the dev branch if you support merging branches that are not up to date? I understand this would be very difficult to enforce given the amount of new PRs, but I'm interested to learn more from your experience in that domain.

@frenck
Copy link
Member

frenck commented Oct 8, 2023

Just curious: how do you guarantee not to break the dev branch if you support merging branches that are not up to date?

We don't. That simple :)
If anything breaks, we'll notice and fix it after that (or revert a PR if needed).

Copy link
Member

@frenck frenck left a comment

Choose a reason for hiding this comment

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

Thanks, @2franix 👍

../Frenck

@frenck frenck merged commit 8c26f66 into home-assistant:dev Oct 8, 2023
34 checks passed
@2franix 2franix deleted the datetime_set_value_sample_not_iso branch October 8, 2023 11:19
@github-actions github-actions bot locked and limited conversation to collaborators Oct 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants