Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
auto-tx
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
vamp
auto-tx
Commits
beaba51e
Commit
beaba51e
authored
7 years ago
by
Niko Ehrenfeuchter
Browse files
Options
Downloads
Patches
Plain Diff
Prevent integer overflow issues with time delta methods.
parent
75c693c6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ATxCommon/TimeUtils.cs
+7
-7
7 additions, 7 deletions
ATxCommon/TimeUtils.cs
ATxService/AutoTx.cs
+1
-1
1 addition, 1 deletion
ATxService/AutoTx.cs
with
8 additions
and
8 deletions
ATxCommon/TimeUtils.cs
+
7
−
7
View file @
beaba51e
...
...
@@ -17,8 +17,8 @@ namespace ATxCommon
/// </summary>
/// <param name="refDate">The reference DateTime to check.</param>
/// <returns>The number of minutes between the reference date and now.</returns>
public
static
int
MinutesSince
(
DateTime
refDate
)
{
return
(
int
)(
DateTime
.
Now
-
refDate
).
TotalMinutes
;
public
static
long
MinutesSince
(
DateTime
refDate
)
{
return
(
long
)(
DateTime
.
Now
-
refDate
).
TotalMinutes
;
}
/// <summary>
...
...
@@ -26,8 +26,8 @@ namespace ATxCommon
/// </summary>
/// <param name="refDate">The reference DateTime to check.</param>
/// <returns>The number of seconds between the reference date and now.</returns>
public
static
int
SecondsSince
(
DateTime
refDate
)
{
return
(
int
)(
DateTime
.
Now
-
refDate
).
TotalSeconds
;
public
static
long
SecondsSince
(
DateTime
refDate
)
{
return
(
long
)(
DateTime
.
Now
-
refDate
).
TotalSeconds
;
}
/// <summary>
...
...
@@ -35,7 +35,7 @@ namespace ATxCommon
/// </summary>
/// <param name="delta">The time span in seconds.</param>
/// <returns>A string describing the duration, e.g. "2 hours 34 minutes".</returns>
public
static
string
SecondsToHuman
(
int
delta
)
{
public
static
string
SecondsToHuman
(
long
delta
)
{
const
int
second
=
1
;
const
int
minute
=
second
*
60
;
const
int
hour
=
minute
*
60
;
...
...
@@ -70,7 +70,7 @@ namespace ATxCommon
/// </summary>
/// <param name="delta">The time span in minutes.</param>
/// <returns>A string describing the duration, e.g. "2 hours 34 minutes".</returns>
public
static
string
MinutesToHuman
(
int
delta
)
{
public
static
string
MinutesToHuman
(
long
delta
)
{
return
SecondsToHuman
(
delta
*
60
);
}
...
...
@@ -79,7 +79,7 @@ namespace ATxCommon
/// </summary>
/// <param name="delta">The time span in days.</param>
/// <returns>A string describing the duration, e.g. "12 days" or "3 weeks".</returns>
public
static
string
DaysToHuman
(
int
delta
)
{
public
static
string
DaysToHuman
(
long
delta
)
{
return
MinutesToHuman
(
delta
*
60
*
24
);
}
}
...
...
This diff is collapsed.
Click to expand it.
ATxService/AutoTx.cs
+
1
−
1
View file @
beaba51e
...
...
@@ -424,7 +424,7 @@ namespace ATxService
Log
.
Error
(
"Unhandled exception in OnTimedEvent(): {0}\n\n"
+
"Trying exponential backoff, setting timer interval to {1} ms ({3}).\n\n"
+
"StackTrace: {2}"
,
ex
.
Message
,
_mainTimer
.
Interval
,
ex
.
StackTrace
,
TimeUtils
.
SecondsToHuman
((
int
)
_mainTimer
.
Interval
/
1000
));
TimeUtils
.
SecondsToHuman
((
long
)
_mainTimer
.
Interval
/
1000
));
}
finally
{
// make sure to enable the timer again:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment