Skip to content

Add proper support for time restrictions which wrap around a day#45

Merged
EightSmart merged 12 commits intodevfrom
dev-time-restrictions
Sep 2, 2025
Merged

Add proper support for time restrictions which wrap around a day#45
EightSmart merged 12 commits intodevfrom
dev-time-restrictions

Conversation

@Syntax505
Copy link
Member

Time restrictions which wrap around a day (e.g. 2300 - 1159z) are presently not implemented correctly, as VFPC would continue to output "OK" for such a restriction even if the current UTC time falls within that range. This PR resolves that issue.

@Syntax505 Syntax505 requested a review from EightSmart September 1, 2025 08:05
@Syntax505 Syntax505 self-assigned this Sep 1, 2025
Copy link
Member

@EightSmart EightSmart left a comment

Choose a reason for hiding this comment

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

I would pull out the time range check logic to avoid duplication and make the code neater

bool withinPeriod;
if (startTimeGreater) {
    withinPeriod = (tm_gmt->tm_hour >= time["start"].get<int>() ||
                    tm_gmt->tm_hour <= time["end"].get<int>());
} else {
    withinPeriod = (tm_gmt->tm_hour >= time["start"].get<int>() &&
                    tm_gmt->tm_hour <= time["end"].get<int>());
}

if (withinPeriod) {
    // Loop through available levels
}

@EightSmart
Copy link
Member

EightSmart commented Sep 1, 2025

Also you don't need the if statement to assign the previous bool:
bool startTimeGreater = time["start"].get<int>() > time["end"].get<int>();

@Syntax505 Syntax505 requested a review from EightSmart September 1, 2025 17:03
@EightSmart EightSmart merged commit 3b02e86 into dev Sep 2, 2025
1 check passed
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.

2 participants