Skip to content
Merged
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
4 changes: 2 additions & 2 deletions features/cellular/framework/AT/AT_CellularSMS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1114,7 +1114,7 @@ int AT_CellularSMS::compare_time_strings(const char *time_string_1, const char *
int retVal = -2;

if (success) {
double diff = difftime(t1, t2);
time_t diff = t1 - t2;

if (diff > 0) {
retVal = 1;
Expand All @@ -1140,7 +1140,7 @@ bool AT_CellularSMS::create_time(const char *time_string, time_t *time)
&time_struct.tm_hour, &time_struct.tm_min, &time_struct.tm_sec, &sign, &gmt) == kNumberOfElements) {
*time = mktime(&time_struct);
// add timezone as seconds. gmt is in quarter of hours.
int x = 60 * 60 * gmt * 0.25;
int x = (60 / 4) * 60 * gmt;
Copy link
Collaborator

Choose a reason for hiding this comment

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

It would make sense to have macros for these magic numbers too.

Copy link
Contributor

Choose a reason for hiding this comment

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

Not convinced "60 seconds in a minute" is that magic. I don't like moving things off to macros elsewhere, unless it's a shared constant that's going to be reused.

If you want to spell it out, you could do so in the variable names themselves:

   &tz_quarter_hours

   int tz_minutes = tz_quarter_hours * 15;
   int tz_seconds = tz_minutes * 60;
   *time += tz_seconds;

(Using %c%d to grab the sign is also a bit weird - sscanf %d will handle + and - itself. Can't see a need to do it manually here).

if (sign == '+') {
*time += x;
} else {
Expand Down