Skip to content

Commit

Permalink
log (fix): Add missing Z for UTC-0 timestamp for Scala Native (#3500)
Browse files Browse the repository at this point in the history
  • Loading branch information
xerial authored Apr 22, 2024
1 parent e89226d commit 3c05c5e
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ object LogTimestampFormatter {
!ttPtr = (timeMillis / 1000).toSize
val tmPtr = alloc[tm]()
localtime_r(ttPtr, tmPtr)
val bufSize = 26.toUSize
val bufSize = 29.toUSize // max size for time strings
val buf: Ptr[Byte] = alloc[Byte](bufSize)
strftime(buf, bufSize, pattern, tmPtr)
val ms = timeMillis % 1000
Expand All @@ -41,7 +41,12 @@ object LogTimestampFormatter {

val tzBuf: Ptr[Byte] = alloc[Byte](5)
strftime(tzBuf, 5.toUSize, c"%z", tmPtr)
strcat(buf, tzBuf)
if (strlen(tzBuf) <= 1.toUSize) {
// For UTC-00:00
strcat(buf, c"Z")
} else {
strcat(buf, tzBuf)
}
fromCString(buf)
}
}
Expand Down

0 comments on commit 3c05c5e

Please sign in to comment.