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

services: fix casting on toast #427

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft

services: fix casting on toast #427

wants to merge 2 commits into from

Conversation

RuffaloLavoisier
Copy link
Member

fix time casting issue on toast feature.

@RuffaloLavoisier RuffaloLavoisier self-assigned this Jan 12, 2025
@RuffaloLavoisier RuffaloLavoisier linked an issue Jan 12, 2025 that may be closed by this pull request
Copy link
Member

@simonmicro simonmicro left a comment

Choose a reason for hiding this comment

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

If you fix this, you should fix all sections interacting with the incorrect time - even in this file are two. Also, did you rerun the unit-tests on your system? Maybe they catch that on MacOS and help you find those issues.

@simonmicro simonmicro force-pushed the feature/ble/basic-server branch from 55f1910 to 1590abd Compare January 12, 2025 11:37
@@ -13,11 +13,12 @@ NotificationData OswServiceTaskNotifier::createNotification(std::chrono::time_po

std::chrono::time_point<std::chrono::system_clock, std::chrono::seconds> getTimeToFire(int hours, int minutes) {
auto utcTime = std::chrono::system_clock::from_time_t(OswHal::getInstance()->getUTCTime());
auto currentTime = utcTime + std::chrono::seconds{static_cast<int>(OswHal::getInstance()->getTimezoneOffsetPrimary())};
auto utcTimeInSeconds = std::chrono::duration_cast<std::chrono::seconds>(utcTime.time_since_epoch());
auto currentTime = utcTimeInSeconds + std::chrono::seconds{static_cast<int>(OswHal::getInstance()->getTimezoneOffsetPrimary())};
auto currentDate = date::sys_days(floor<date::days>(currentTime));
auto scheduledTime = std::chrono::hours{hours} + std::chrono::minutes{minutes} + std::chrono::seconds{0};
auto timeToFire = currentDate + scheduledTime;
Copy link
Member

Choose a reason for hiding this comment

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

This is a duration, right? Why did you not cast here?

if (auto it = scheduler.begin();
it != scheduler.end() && currentTime >= it->first) {
it != scheduler.end() && currentTime.count() >= it->first.time_since_epoch().count()) {
Copy link
Member

Choose a reason for hiding this comment

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

...same here?

Base automatically changed from feature/ble/basic-server to develop January 12, 2025 20:40
@RuffaloLavoisier RuffaloLavoisier marked this pull request as draft January 12, 2025 20:44
@simonmicro simonmicro force-pushed the develop branch 2 times, most recently from 890efcf to 9478a8e Compare January 14, 2025 11:20
@simonmicro simonmicro added this to the v0.18.1 milestone Jan 18, 2025
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.

Toast message service is not working
2 participants