Skip to content

Commit

Permalink
Addressed comments
Browse files Browse the repository at this point in the history
  • Loading branch information
rasmus-kirk committed Oct 26, 2023
1 parent a0fbef9 commit d264030
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
## 4.1.0
- Bugfix
- Documentation was missing when adding library as nuget packages and hovering over methods and classes.
- Added
- gRPC queries relevant for smart contracts.
- GetModuleListAsync
- GetInstanceListAsync
Expand Down
15 changes: 13 additions & 2 deletions src/Types/TransactionTime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ internal static TransactionTime From(Grpc.V2.TransactionTime transactionTime) =>
new(transactionTime.Value);

/// <summary>Convert the TransactionTime to a DateTimeOffset.</summary>
public DateTimeOffset ToDateTimeOffset() =>
DateTimeOffset.FromUnixTimeSeconds((long)this.SecondsSinceUnixEpoch);
public DateTimeOffset ToDateTimeOffset()
{
if (this.SecondsSinceUnixEpoch > long.MaxValue)
{
throw new ArgumentOutOfRangeException(
$"The timestamp has a value of {this.SecondsSinceUnixEpoch} which exceeds the maximum value of supported by DateTimeOffset."
);
}
else
{
return DateTimeOffset.FromUnixTimeSeconds((long)this.SecondsSinceUnixEpoch);
}
}
}

0 comments on commit d264030

Please sign in to comment.