Skip to content

Commit 3ab7b14

Browse files
committed
fix: deadline header with correct instant value (#551)
1 parent 262c3b5 commit 3ab7b14

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

Sources/AWSLambdaRuntime/LambdaClock.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public struct LambdaClock: Clock {
6262
/// ## Thread Safety
6363
///
6464
/// `Instant` is a value type and is inherently thread-safe.
65-
public struct Instant: InstantProtocol {
65+
public struct Instant: InstantProtocol, CustomStringConvertible {
6666
/// The number of milliseconds since the Unix epoch.
6767
let instant: Int64
6868

@@ -122,6 +122,11 @@ public struct LambdaClock: Clock {
122122
public init(millisecondsSinceEpoch milliseconds: Int64) {
123123
self.instant = milliseconds
124124
}
125+
126+
/// Renders an Instant as an EPOCH value
127+
public var description: String {
128+
"\(self.instant)"
129+
}
125130
}
126131

127132
/// The current instant according to this clock.

Tests/AWSLambdaRuntimeTests/LambdaClockTests.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,4 +136,12 @@ struct LambdaClockTests {
136136
"LambdaClock and Foundation Date should be within 10ms of each other, difference was \(difference)ms"
137137
)
138138
}
139+
@Test("Instant renders as string with an epoch number")
140+
func instantRendersAsStringWithEpochNumber() {
141+
let clock = LambdaClock()
142+
let instant = clock.now
143+
144+
let expectedString = "\(instant)"
145+
#expect(expectedString.allSatisfy { $0.isNumber }, "String should only contain numbers")
146+
}
139147
}

0 commit comments

Comments
 (0)