MCPcopy Create free account
hub / github.com/bytebase/bytebase / formatTimestamp

Function formatTimestamp

frontend/src/utils/v1/sql.ts:95–108  ·  view source on GitHub ↗
(timestamp: RowValue_Timestamp)

Source from the content-addressed store, hash-verified

93};
94
95const formatTimestamp = (timestamp: RowValue_Timestamp) => {
96 const fullDayjs = dayjs(
97 getDateForPbTimestampProtoEs(timestamp.googleTimestamp)
98 ).utc();
99 const microseconds = Math.floor(
100 (timestamp.googleTimestamp?.nanos ?? 0) /
101 Math.pow(10, 9 - timestamp.accuracy)
102 );
103 const formattedTimestamp =
104 microseconds > 0
105 ? `${fullDayjs.format("YYYY-MM-DD HH:mm:ss")}.${microseconds.toString().padStart(timestamp.accuracy, "0")}`
106 : `${fullDayjs.format("YYYY-MM-DD HH:mm:ss")}`;
107 return formattedTimestamp;
108};
109
110const formatTimestampWithTz = (timestampTzValue: RowValue_TimestampTZ) => {
111 const fullDayjs = dayjs(

Callers 1

extractSQLRowValuePlainFunction · 0.70

Calls 2

toStringMethod · 0.65

Tested by

no test coverage detected