Skip to content

Commit 1a06cb4

Browse files
authored
Merge pull request #89 from djmitche/issue88
Use 64-bit delta for Datetime +/- operators
2 parents d98ff85 + f822245 commit 1a06cb4

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/Datetime.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3788,26 +3788,26 @@ bool Datetime::sameYear (const Datetime& rhs) const
37883788
}
37893789

37903790
////////////////////////////////////////////////////////////////////////////////
3791-
Datetime Datetime::operator+ (const int delta)
3791+
Datetime Datetime::operator+ (const int64_t delta)
37923792
{
37933793
return { _date + delta };
37943794
}
37953795

37963796
////////////////////////////////////////////////////////////////////////////////
3797-
Datetime Datetime::operator- (const int delta)
3797+
Datetime Datetime::operator- (const int64_t delta)
37983798
{
37993799
return { _date - delta };
38003800
}
38013801

38023802
////////////////////////////////////////////////////////////////////////////////
3803-
Datetime& Datetime::operator+= (const int delta)
3803+
Datetime& Datetime::operator+= (const int64_t delta)
38043804
{
38053805
_date += (time_t) delta;
38063806
return *this;
38073807
}
38083808

38093809
////////////////////////////////////////////////////////////////////////////////
3810-
Datetime& Datetime::operator-= (const int delta)
3810+
Datetime& Datetime::operator-= (const int64_t delta)
38113811
{
38123812
_date -= (time_t) delta;
38133813
return *this;

src/Datetime.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
#include <Pig.h>
3131
#include <ctime>
32+
#include <cstdint>
3233
#include <string>
3334

3435
#define EPOCH_MIN_VALUE 315532800 // 1980-01-01T00:00:00Z
@@ -101,10 +102,10 @@ class Datetime
101102
bool sameMonth (const Datetime&) const;
102103
bool sameQuarter (const Datetime&) const;
103104
bool sameYear (const Datetime&) const;
104-
Datetime operator+ (const int);
105-
Datetime operator- (const int);
106-
Datetime& operator+= (const int);
107-
Datetime& operator-= (const int);
105+
Datetime operator+ (const int64_t);
106+
Datetime operator- (const int64_t);
107+
Datetime& operator+= (const int64_t);
108+
Datetime& operator-= (const int64_t);
108109
time_t operator- (const Datetime&);
109110
void operator-- (); // Prefix
110111
void operator-- (int); // Postfix

0 commit comments

Comments
 (0)