Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve tmToString and relating document #8250

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
6 changes: 1 addition & 5 deletions velox/type/Timestamp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,11 +306,7 @@ std::string Timestamp::tmToString(
}
} else {
while (nanos > 0) {
if (nanos % 10 == 0) {
out += '0';
} else {
out += '0' + nanos % 10;
}
out += '0' + nanos % 10;
nanos /= 10;
}
}
Expand Down
8 changes: 6 additions & 2 deletions velox/type/Timestamp.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,14 @@ struct TimestampToStringOptions {
// Whether to add a leading '+' when year is greater than 9999.
bool leadingPositiveSign = false;

// Whether to skip trailing zeros of fractional part.
/// Whether to skip trailing zeros of fractional part. E.g. when true,
/// '2000-01-01 12:21:56.129000' becomes '2000-01-01 12:21:56.129'.
bool skipTrailingZeros = false;

// Whether padding zeros are added when the digits of year is less than 4.
/// Whether padding zeros are added when the digits of year is less than 4.
/// E.g. when true, '1-01-01 05:17:32.000' becomes '0001-01-01 05:17:32.000',
/// '-03-24 13:20:00.000' becomes '0000-03-24 13:20:00.000', and '-1-11-29
/// 19:33:20.000' becomes '-0001-11-29 19:33:20.000'.
bool zeroPaddingYear = false;

// The separator of date and time.
Expand Down