Skip to content

Commit

Permalink
Fixes [ads] Crash "brave_ads::GetLocalMidnight" (uplift to 1.60.x) (#…
Browse files Browse the repository at this point in the history
…20641)

Uplift of #20627 (squashed) to beta
  • Loading branch information
brave-builds authored Oct 23, 2023
1 parent a602fd4 commit 805d3d7
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ base::Time CalculateNextPaymentDate(const base::Time next_token_redemption_at,

base::Time::Exploded now_exploded;
now.UTCExplode(&now_exploded);
CHECK(now_exploded.HasValidValues());

int month = now_exploded.month;

Expand All @@ -40,7 +39,6 @@ base::Time CalculateNextPaymentDate(const base::Time next_token_redemption_at,
} else {
base::Time::Exploded next_token_redemption_at_exploded;
next_token_redemption_at.UTCExplode(&next_token_redemption_at_exploded);
CHECK(next_token_redemption_at_exploded.HasValidValues());

if (next_token_redemption_at_exploded.month == month) {
// If this month does not have reconciled transactions and our next
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ int GetDayOfWeek(const base::Time time, const bool is_local) {
} else {
time.UTCExplode(&exploded);
}
CHECK(exploded.HasValidValues());

return exploded.day_of_week;
}
Expand Down
10 changes: 0 additions & 10 deletions components/brave_ads/core/internal/common/time/time_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

#include "brave/components/brave_ads/core/internal/common/time/time_util.h"

#include "base/check.h"
#include "base/strings/stringprintf.h"
#include "base/time/time.h"
#include "brave/components/brave_ads/core/internal/common/calendar/calendar_util.h"
Expand All @@ -23,7 +22,6 @@ base::Time CorrectLocalMidnightForDaylightSaving(const base::Time midnight,
// Check for errors due to daylight saving time change.
base::Time::Exploded midnight_exploded;
midnight.LocalExplode(&midnight_exploded);
CHECK(midnight_exploded.HasValidValues());

base::Time corrected_midnight = midnight;
if (midnight_exploded.hour != 0) {
Expand All @@ -41,7 +39,6 @@ base::Time CorrectLocalMidnightForDaylightSaving(const base::Time midnight,
base::Time CalculateBeginningOfMonth(const base::Time time) {
base::Time::Exploded exploded;
time.LocalExplode(&exploded);
CHECK(exploded.HasValidValues());

const base::Time midnight = GetLocalMidnight(time);
const base::Time shifted_midnight =
Expand All @@ -55,7 +52,6 @@ base::Time CalculateBeginningOfMonth(const base::Time time) {
base::Time CalculateBeginningOfNextMonth(const base::Time time) {
base::Time::Exploded exploded;
time.LocalExplode(&exploded);
CHECK(exploded.HasValidValues());

const base::Time midnight = GetLocalMidnight(time);
const base::Time shifted_midnight =
Expand Down Expand Up @@ -95,7 +91,6 @@ base::Time CalculateEndOfMonth(const base::Time time) {
base::Time GetLocalMidnight(const base::Time time) {
base::Time::Exploded exploded;
time.LocalExplode(&exploded);
CHECK(exploded.HasValidValues());

const base::Time midnight =
time - base::Hours(exploded.hour) - base::Minutes(exploded.minute) -
Expand All @@ -107,7 +102,6 @@ base::Time GetLocalMidnight(const base::Time time) {
int GetLocalTimeInMinutes(const base::Time time) {
base::Time::Exploded exploded;
time.LocalExplode(&exploded);
CHECK(exploded.HasValidValues());

const base::TimeDelta time_delta =
base::Hours(exploded.hour) + base::Minutes(exploded.minute);
Expand All @@ -117,7 +111,6 @@ int GetLocalTimeInMinutes(const base::Time time) {
base::Time AdjustLocalTimeToBeginningOfPreviousMonth(const base::Time time) {
base::Time::Exploded exploded;
time.LocalExplode(&exploded);
CHECK(exploded.HasValidValues());

exploded.month--;
if (exploded.month < 1) {
Expand Down Expand Up @@ -147,7 +140,6 @@ base::Time AdjustLocalTimeToBeginningOfPreviousMonth(const base::Time time) {
base::Time AdjustLocalTimeToEndOfPreviousMonth(const base::Time time) {
base::Time::Exploded exploded;
time.LocalExplode(&exploded);
CHECK(exploded.HasValidValues());

exploded.month--;
if (exploded.month < 1) {
Expand Down Expand Up @@ -177,7 +169,6 @@ base::Time AdjustLocalTimeToEndOfPreviousMonth(const base::Time time) {
base::Time AdjustLocalTimeToBeginningOfMonth(const base::Time time) {
base::Time::Exploded exploded;
time.LocalExplode(&exploded);
CHECK(exploded.HasValidValues());

exploded.day_of_month = 1;

Expand All @@ -201,7 +192,6 @@ base::Time AdjustLocalTimeToBeginningOfMonth(const base::Time time) {
base::Time AdjustLocalTimeToEndOfMonth(const base::Time time) {
base::Time::Exploded exploded;
time.LocalExplode(&exploded);
CHECK(exploded.HasValidValues());

exploded.day_of_month = GetLastDayOfMonth(exploded.year, exploded.month);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

#include <string>

#include "base/check.h"
#include "base/ranges/algorithm.h"
#include "base/strings/stringprintf.h"
#include "base/time/time.h"
Expand All @@ -20,7 +19,6 @@ namespace {
std::string GetFormattedBalanceDate(const base::Time time) {
base::Time::Exploded exploded;
time.LocalExplode(&exploded);
CHECK(exploded.HasValidValues());

return base::StringPrintf("%04d-%02d", exploded.year, exploded.month);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

#include "brave/components/brave_ads/core/internal/serving/permission_rules/do_not_disturb_permission_rule.h"

#include "base/check.h"
#include "base/time/time.h"
#include "brave/components/brave_ads/core/internal/browser/browser_manager.h"
#include "brave/components/brave_ads/core/internal/common/platform/platform_helper.h"
Expand All @@ -30,7 +29,6 @@ bool DoesRespectCap() {
const base::Time time = base::Time::Now();
base::Time::Exploded exploded;
time.LocalExplode(&exploded);
CHECK(exploded.HasValidValues());

return exploded.hour >= kDoNotDisturbToHour &&
exploded.hour < kDoNotDisturbFromHour;
Expand Down

0 comments on commit 805d3d7

Please sign in to comment.