Repository navigation
fix(new-webui): Modify all timestamps to UTC timezone. #1000
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
Changes from 3 commits
02c3261
a3d8f53
0ab4068
84c9635
380ed08
d0f2800
ccbecac
0d47fb0
5ef79c9
15c7e04
70a2736
eaf4939
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,6 +45,12 @@ const TimeRangeInput = () => { | |
| if (!isValidDateRange(dates)) { | ||
| return; | ||
| } | ||
|
|
||
| console.debug("Selected date range:", { | ||
| start: dates[0].format("YYYY-MM-DD HH:mm:ss Z"), | ||
| end: dates[1].format("YYYY-MM-DD HH:mm:ss Z"), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shall we use constants for the format strings?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will just remove this. its not neccesary |
||
| }); | ||
|
|
||
| updateTimeRange(dates); | ||
| }; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| import dayjs from "dayjs"; | ||
|
|
||
| import DayjsUtc from "dayjs/plugin/utc"; | ||
| dayjs.extend(DayjsUtc); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Centralise Dayjs UTC plugin extension to avoid repetitive side-effects Importing and extending import DayjsUtc from "dayjs/plugin/utc";
dayjs.extend(DayjsUtc);into a single bootstrap/module (e.g., 🤖 Prompt for AI Agents |
||
|
|
||
| /** | ||
| * Time range options. | ||
|
|
@@ -22,31 +23,33 @@ const DEFAULT_TIME_RANGE = TIME_RANGE_OPTION.ALL_TIME; | |
|
|
||
| /* eslint-disable no-magic-numbers */ | ||
| const TIME_RANGE_OPTION_DAYJS_MAP: Record<TIME_RANGE_OPTION, [dayjs.Dayjs, dayjs.Dayjs]> = { | ||
| [TIME_RANGE_OPTION.LAST_15_MINUTES]: [dayjs().subtract(15, "minute"), | ||
| dayjs()], | ||
| [TIME_RANGE_OPTION.LAST_HOUR]: [dayjs().subtract(1, "hour"), | ||
| dayjs()], | ||
| [TIME_RANGE_OPTION.TODAY]: [dayjs().startOf("day"), | ||
| dayjs().endOf("day")], | ||
| [TIME_RANGE_OPTION.YESTERDAY]: [dayjs().subtract(1, "d"), | ||
| dayjs().subtract(2, "d")], | ||
| [TIME_RANGE_OPTION.LAST_7_DAYS]: [dayjs().subtract(7, "d"), | ||
| dayjs()], | ||
| [TIME_RANGE_OPTION.LAST_30_DAYS]: [dayjs().subtract(30, "d"), | ||
| dayjs()], | ||
| [TIME_RANGE_OPTION.LAST_12_MONTHS]: [dayjs().subtract(12, "month"), | ||
| dayjs()], | ||
| [TIME_RANGE_OPTION.MONTH_TO_DATE]: [dayjs().startOf("month"), | ||
| dayjs()], | ||
| [TIME_RANGE_OPTION.YEAR_TO_DATE]: [dayjs().startOf("year"), | ||
| dayjs()], | ||
| [TIME_RANGE_OPTION.ALL_TIME]: [dayjs(0), | ||
| dayjs().add(1, "year")], | ||
| [TIME_RANGE_OPTION.LAST_15_MINUTES]: [dayjs.utc().subtract(15, "minute"), | ||
| dayjs.utc()], | ||
| [TIME_RANGE_OPTION.LAST_HOUR]: [dayjs.utc().subtract(1, "hour"), | ||
| dayjs.utc()], | ||
| [TIME_RANGE_OPTION.TODAY]: [dayjs.utc().startOf("day"), | ||
| dayjs.utc().endOf("day")], | ||
| [TIME_RANGE_OPTION.YESTERDAY]: [dayjs.utc().subtract(1, "d") | ||
| .startOf("day"), | ||
| dayjs.utc().subtract(1, "d") | ||
| .endOf("day")], | ||
| [TIME_RANGE_OPTION.LAST_7_DAYS]: [dayjs.utc().subtract(7, "d"), | ||
| dayjs.utc()], | ||
| [TIME_RANGE_OPTION.LAST_30_DAYS]: [dayjs.utc().subtract(30, "d"), | ||
| dayjs.utc()], | ||
| [TIME_RANGE_OPTION.LAST_12_MONTHS]: [dayjs.utc().subtract(12, "month"), | ||
| dayjs.utc()], | ||
| [TIME_RANGE_OPTION.MONTH_TO_DATE]: [dayjs.utc().startOf("month"), | ||
| dayjs.utc()], | ||
| [TIME_RANGE_OPTION.YEAR_TO_DATE]: [dayjs.utc().startOf("year"), | ||
| dayjs.utc()], | ||
| [TIME_RANGE_OPTION.ALL_TIME]: [dayjs.utc(0), | ||
| dayjs.utc().add(1, "year")], | ||
|
|
||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| // Custom option is just a placeholder for typing purposes, its DayJs values should not | ||
| // be used. | ||
| [TIME_RANGE_OPTION.CUSTOM]: [dayjs(), | ||
| dayjs()], | ||
| [TIME_RANGE_OPTION.CUSTOM]: [dayjs.utc(), | ||
| dayjs.utc()], | ||
| }; | ||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,7 +32,7 @@ const searchResultsTableColumns: NonNullable<TableProps<SearchResult>["columns"] | |
| dataIndex: "timestamp", | ||
| defaultSortOrder: "ascend", | ||
| key: "timestamp", | ||
| render: (timestamp: number) => dayjs(timestamp).format(DATETIME_FORMAT_TEMPLATE), | ||
| render: (timestamp: number) => dayjs.utc(timestamp).format(DATETIME_FORMAT_TEMPLATE), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| sorter: (a, b) => a.timestamp - b.timestamp, | ||
|
|
||
| // Specifying a third sort direction removes ability for user to cancel sorting. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a question -
would it be better to create/store a UTC object in the query store in the first place?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Im not sure i fully get your question, but I believe the timestamp is in utc, its just that dayJs dosent know that. So this change basically lets dayJs know the timestamp is in utc
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like shall we change these lines
clp/components/log-viewer-webui/client/src/pages/IngestPage/Details/index.tsx
Lines 56 to 57 in e90fe05
or
then we can avoid the UTC conversions when the dates are consumed in the rendering functions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay that can work too