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

feat: add timezone_to_second/1 function to rule engine #10858

Conversation

kjellwinblad
Copy link
Contributor

@kjellwinblad kjellwinblad commented May 29, 2023

This commit adds the functions timezone_to_offset_seconds and its alias timezone_to_second to the rule engine. As the names suggests, these functions convert a timzone offset string such as "+02:00", "Z", "local" to an integer representing how many seconds that the given timezone differs from UTC. timezone_to_offset_seconds is the one of the two functions that should be advertised while timezone_to_second in kept for backwards compatibility with 4.X.

Fixes:
https://emqx.atlassian.net/browse/EMQX-10058

Summary

🤖 Generated by Copilot at 995025b

Added timezone conversion functions and tests to emqx_rule_funcs and updated emqx_machine version.

PR Checklist

Please convert it to a draft if any of the following conditions are not met. Reviewers may skip over until all the items are checked:

  • Added tests for the changes
  • Changed lines covered in coverage report
  • Change log has been added to changes/{ce,ee}/(feat|perf|fix)-<PR-id>.en.md files
  • For internal contributor: there is a jira ticket to track this change
  • If there should be document changes, a PR to emqx-docs.git is sent, or a jira ticket is created to follow up
  • Schema changes are backward compatible

This commit adds the functions timezone_to_offset_seconds and its alias
timezone_to_second to the rule engine. As the names suggests, these
functions convert a timzone offset string such as "+02:00", "Z", "local"
to an integer representing how many seconds that the given timezone
differs from UTC. timezone_to_offset_seconds is the one of the two
functions that should be advertised while timezone_to_second in kept for
backwards compatibility with 4.X.

Fixes:
https://emqx.atlassian.net/browse/EMQX-10058
@kjellwinblad kjellwinblad requested a review from a team as a code owner May 29, 2023 12:35
zmstone
zmstone previously approved these changes May 29, 2023
qzhuyan
qzhuyan previously approved these changes May 29, 2023
thalesmg
thalesmg previously approved these changes May 29, 2023
paulozulato
paulozulato previously approved these changes May 29, 2023
@kjellwinblad
Copy link
Contributor Author

Sorry, the test suite was broken but has been fixed by this commit (354603d) so I need another approval.

@coveralls
Copy link
Collaborator

Pull Request Test Coverage Report for Build 5113281055

  • 2 of 2 (100.0%) changed or added relevant lines in 1 file are covered.
  • 34 unchanged lines in 12 files lost coverage.
  • Overall coverage increased (+0.007%) to 81.622%

Files with Coverage Reduction New Missed Lines %
apps/emqx_management/src/emqx_mgmt_util.erl 1 13.79%
apps/emqx_modules/src/emqx_delayed.erl 1 95.65%
apps/emqx/src/emqx_cm.erl 1 91.6%
apps/emqx/src/emqx_config_handler.erl 1 96.25%
apps/emqx/src/emqx_logger_textfmt.erl 1 59.09%
apps/emqx/src/emqx_session.erl 1 87.25%
apps/emqx_resource/src/emqx_resource_buffer_worker.erl 2 93.09%
apps/emqx/src/emqx_broker.erl 2 87.64%
apps/emqx/src/emqx_channel.erl 2 87.69%
apps/emqx_gateway_exproto/src/emqx_exproto_gcli.erl 3 48.78%
Totals Coverage Status
Change from base Build 5111811576: 0.007%
Covered Lines: 28656
Relevant Lines: 35108

💛 - Coveralls

@kjellwinblad kjellwinblad merged commit 5cfe049 into emqx:master May 30, 2023
165 checks passed
@yanzhiemq
Copy link
Collaborator

yanzhiemq commented Jun 13, 2023

Enhancements

  • A new utility function timezone_to_offset_seconds/1 has been added to the rule engine SQL language. This function converts a timezone string (for example, "+02:00", "Z" and "local") to the corresponding offset in seconds.

@yanzhiemq
Copy link
Collaborator

yanzhiemq commented Jun 13, 2023

增强

  • 规则引擎 SQL 语言新增了一个实用函数 timezone_to_offset_seconds/1。该函数将时区字符串(例如"+02:00"、"Z"和"local")转换为相应的偏移秒数。

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.

None yet

7 participants