Consistent data formatting

This commit is contained in:
Guntis Smaukstelis
2025-02-05 23:35:40 +02:00
parent 9c8902e746
commit af9debbb2e
3 changed files with 6 additions and 5 deletions
@@ -78,5 +78,4 @@ class FetchService(log: Logger[IO]) {
} yield fileNameStr
}
}
}
+1 -1
View File
@@ -29,7 +29,7 @@ object FileName {
.withNano(0)
}
// TODO make default count to 62 or 60
// TODO make default count to 61
def generateTimeList(initialTime: ZonedDateTime, interval: Int = 1, count: Int = 5): List[ZonedDateTime] = {
(0 until count).map(id => initialTime.plusHours(id * interval)).toList
}
+5 -3
View File
@@ -4,6 +4,7 @@ import cats.effect._
import fs2.io.file.{Files, Path}
import java.nio.ByteBuffer
import java.time.format.DateTimeFormatter
import java.time.temporal.ChronoUnit
import java.time.{ZoneOffset, ZonedDateTime}
@@ -116,7 +117,7 @@ object GribParser {
meteoParam = MeteoParam(discipline, category, product, subtype, levelType, levelValue)
forecastTime = if (bytes(8) == 1) {
val leadTime = ByteBuffer.wrap(bytes.slice(20, 22)).getShort
referenceTime.toInstant.plus(leadTime, ChronoUnit.HOURS)
referenceTime.plus(leadTime, ChronoUnit.HOURS)
} else {
val year = ByteBuffer.wrap(bytes.slice(37, 39)).getShort
val month = bytes(39)
@@ -128,9 +129,9 @@ object GribParser {
year, month, day,
hour, minute, second, 0, // last 0 is nanos
ZoneOffset.UTC // This is what 'Z' represents - UTC/Zero offset
).toInstant
)
}
time = GribTime(referenceTime.toString, forecastTime.toString)
time = GribTime(referenceTime.format(formatter), forecastTime.format(formatter))
} yield (meteoParam, time, length)
}
@@ -165,4 +166,5 @@ object GribParser {
.compile
.to(Array)
}
private val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HHmmX")
}