8000 chore: replace date-fns by dayjs by BrunoQuaresma · Pull Request #18022 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

chore: replace date-fns by dayjs #18022

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

Merged
merged 8 commits into from
May 25, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix time from
  • Loading branch information
BrunoQuaresma committed May 25, 2025
commit 2c987c402637b50366850498aabe1bdafcf7236b
6 changes: 3 additions & 3 deletions site/src/pages/WorkspacePage/AppStatuses.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
TooltipProvider,
TooltipTrigger,
} from "components/Tooltip/Tooltip";
import { timeFromNow } from "utils/time";
import { timeFrom } from "utils/time";

import {
ChevronDownIcon,
Expand Down Expand Up @@ -154,7 +154,7 @@ export const AppStatuses: FC<AppStatusesProps> = ({
{latestStatus.message}
</span>
<span className="text-xs text-content-secondary first-letter:uppercase block pl-[26px]">
{timeFromNow(new Date(latestStatus.created_at), comparisonDate)}
{timeFrom(new Date(latestStatus.created_at), comparisonDate)}
</span>
</div>

Expand Down Expand Up @@ -215,7 +215,7 @@ export const AppStatuses: FC<AppStatusesProps> = ({
{displayStatuses &&
otherStatuses.map((status) => {
const statusTime = new Date(status.created_at);
const formattedTimestamp = timeFromNow(statusTime, comparisonDate);
const formattedTimestamp = timeFrom(statusTime, comparisonDate);

return (
<div
Expand Down
7 changes: 3 additions & 4 deletions site/src/utils/time.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,11 @@ export function relativeTimeWithoutSuffix(date: DateTimeInput) {
return dayjs(date).fromNow(true);
}

export function timeFromNow(
export function timeFrom(
date: DateTimeInput,
referenceDate?: DateTimeInput,
referenceDate: DateTimeInput = new Date(),
) {
const reference = referenceDate ? dayjs(referenceDate) : dayjs();
return reference.from(dayjs(date));
return dayjs(date).from(dayjs(referenceDate));
}

// Time manipulation functions
Expand Down
Loading
0