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

Fix BAP date calculation (uplift to 1.21.x) #7933

Merged
merged 1 commit into from
Feb 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions components/brave_rewards/browser/rewards_service_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1494,8 +1494,9 @@ bool RewardsServiceImpl::GetBooleanOption(const std::string& name) const {
base::Time::Exploded cutoff_exploded{
.year = 2021, .month = 3, .day_of_month = 13};
base::Time cutoff;
DCHECK(base::Time::FromUTCExploded(cutoff_exploded, &cutoff));
if (base::Time::Now() >= cutoff) {
bool ok = base::Time::FromUTCExploded(cutoff_exploded, &cutoff);
DCHECK(ok);
if (ok && base::Time::Now() >= cutoff) {
return true;
}
}
Expand Down
8 changes: 4 additions & 4 deletions components/brave_rewards/browser/test/rewards_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ namespace {

base::Time GetDate(int year, int month, int day_of_month) {
base::Time time;
DCHECK(base::Time::FromUTCExploded(
bool ok = base::Time::FromUTCExploded(
base::Time::Exploded{
.year = year, .month = month, .day_of_month = day_of_month},
&time));
&time);
DCHECK(ok);
return time;
}

Expand Down Expand Up @@ -482,8 +483,7 @@ IN_PROC_BROWSER_TEST_F(RewardsBrowserTest, BAPCutoffBefore) {

{
base::subtle::ScopedTimeClockOverrides time_override(
[]() { return GetDate(2021, 3, 13) - base::TimeDelta::FromSeconds(1); },
nullptr, nullptr);
[]() { return GetDate(2021, 3, 12); }, nullptr, nullptr);
ASSERT_EQ(FetchBalance(), 30.0);
}
}
Expand Down