Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions core/trino-main/src/main/java/io/trino/type/DateTimes.java
Original file line number Diff line number Diff line change
Expand Up @@ -648,10 +648,13 @@ public static LongTimestampWithTimeZone longTimestampWithTimeZone(long precision
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No tests?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! :)

checkArgument(precision <= TimestampWithTimeZoneType.MAX_PRECISION, "Precision is out of range");

return LongTimestampWithTimeZone.fromEpochMillisAndFraction(
start.toEpochMilli(),
(int) round((start.getNano() % NANOSECONDS_PER_MILLISECOND) * PICOSECONDS_PER_NANOSECOND, (int) (TimestampWithTimeZoneType.MAX_PRECISION - precision)),
timeZoneKey);
long epochMilli = start.toEpochMilli();
int picosOfMilli = (int) round((start.getNano() % NANOSECONDS_PER_MILLISECOND) * PICOSECONDS_PER_NANOSECOND, (int) (TimestampWithTimeZoneType.MAX_PRECISION - precision));
if (picosOfMilli == PICOSECONDS_PER_MILLISECOND) {
epochMilli++;
picosOfMilli = 0;
}
return LongTimestampWithTimeZone.fromEpochMillisAndFraction(epochMilli, picosOfMilli, timeZoneKey);
}

public static LongTimestampWithTimeZone longTimestampWithTimeZone(long epochSecond, long fractionInPicos, ZoneId zoneId)
Expand Down