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
Move some datetime functions to @openshift-console/plugin-shared #12037
Move some datetime functions to @openshift-console/plugin-shared #12037
Conversation
05836e4
to
0448e82
Compare
export const toISODateString = (date: Date): string => | ||
`${date.getFullYear()}-${zeroPad(date.getMonth() + 1)}-${zeroPad(date.getDate())}`; | ||
|
||
export const twentyFourHourTime = (date: Date, showSeconds?: boolean): string => { |
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.
Any reason plugins shouldn't use the standard Intl.DateTimeFormat
for this instead of writing a separate utility? Something like
new Intl.DateTimeFormat(
'en',
{
hour: 'numeric',
minute: 'numeric',
second: 'numeric',
hourCycle: 'h23',
}
).format(date);
Then we can format for the user's locale as well.
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.
Thanks @spadgett. I removed toISODateString
and twentyFourHourTime
from this PR and will address them with a separate PR.
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.
PR for cleaning up the use of toISODateString
and twentyFourHourTime
: #12053
0448e82
to
95d0535
Compare
@@ -1 +1,2 @@ | |||
export * from './components'; | |||
export * from './utils'; |
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.
Can I suggest a package like datetime
that has a more specific meaning instead of a generic utils
package?
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.
👍
const w = d * 7; | ||
const units = { w, d, h, m, s }; | ||
|
||
// Formats a duration in milliseconds like "1h 10m" |
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.
I don't think we're generating docs for console-plugin-shared yet, but it would be good to add ts-doc here for when we do.
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.
👍
Move formatPrometheusDuration and parsePrometheusDuration to @openshift-console/plugin-shared
95d0535
to
673d272
Compare
/retest |
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.
/lgtm
This impacts the user facing API, so requesting approvals. /cc @RickJWagner /cc @opayne1 |
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.
No complaints from PLM.
/label px-approved |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: kyoto, RickJWagner, spadgett The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/label docs-approved |
test PR with cluster bot, no other regression issues. |
Move
formatPrometheusDuration
andparsePrometheusDuration
to @openshift-console/plugin-shared