mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
feat: format date based on language for repacks
This commit is contained in:
parent
a4475d2145
commit
8cc8b5fe6f
4 changed files with 19 additions and 11 deletions
|
@ -68,12 +68,17 @@ export function useDate() {
|
|||
}
|
||||
},
|
||||
|
||||
format: (timestamp: number): string => {
|
||||
formatDateTime: (date: number | Date | string): string => {
|
||||
const locale = getDateLocale();
|
||||
return format(
|
||||
timestamp,
|
||||
date,
|
||||
locale == enUS ? "MM/dd/yyyy - HH:mm" : "dd/MM/yyyy - HH:mm"
|
||||
);
|
||||
},
|
||||
|
||||
formatDate: (date: number | Date | string): string => {
|
||||
const locale = getDateLocale();
|
||||
return format(date, locale == enUS ? "MM/dd/yyyy" : "dd/MM/yyyy");
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ export function Achievement() {
|
|||
|
||||
const { t } = useTranslation("achievement");
|
||||
|
||||
const { format } = useDate();
|
||||
const { formatDateTime } = useDate();
|
||||
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
|
@ -163,7 +163,8 @@ export function Achievement() {
|
|||
<p>{achievement.displayName}</p>
|
||||
<p>{achievement.description}</p>
|
||||
<small>
|
||||
{achievement.unlockTime && format(achievement.unlockTime)}
|
||||
{achievement.unlockTime &&
|
||||
formatDateTime(achievement.unlockTime)}
|
||||
</small>
|
||||
</div>
|
||||
</li>
|
||||
|
|
|
@ -7,11 +7,11 @@ import type { GameRepack } from "@types";
|
|||
import * as styles from "./repacks-modal.css";
|
||||
|
||||
import { SPACING_UNIT } from "@renderer/theme.css";
|
||||
import { format } from "date-fns";
|
||||
import { DownloadSettingsModal } from "./download-settings-modal";
|
||||
import { gameDetailsContext } from "@renderer/context";
|
||||
import { Downloader } from "@shared";
|
||||
import { orderBy } from "lodash-es";
|
||||
import { useDate } from "@renderer/hooks";
|
||||
|
||||
export interface RepacksModalProps {
|
||||
visible: boolean;
|
||||
|
@ -36,6 +36,8 @@ export function RepacksModal({
|
|||
|
||||
const { t } = useTranslation("game_details");
|
||||
|
||||
const { formatDate } = useDate();
|
||||
|
||||
const sortedRepacks = useMemo(() => {
|
||||
return orderBy(repacks, (repack) => repack.uploadDate, "desc");
|
||||
}, [repacks]);
|
||||
|
@ -109,9 +111,7 @@ export function RepacksModal({
|
|||
|
||||
<p style={{ fontSize: "12px" }}>
|
||||
{repack.fileSize} - {repack.repacker} -{" "}
|
||||
{repack.uploadDate
|
||||
? format(repack.uploadDate, "dd/MM/yyyy")
|
||||
: ""}
|
||||
{repack.uploadDate ? formatDate(repack.uploadDate!) : ""}
|
||||
</p>
|
||||
</Button>
|
||||
);
|
||||
|
|
|
@ -60,7 +60,7 @@ export function Sidebar() {
|
|||
useContext(gameDetailsContext);
|
||||
|
||||
const { t } = useTranslation("game_details");
|
||||
const { format } = useDate();
|
||||
const { formatDateTime } = useDate();
|
||||
|
||||
const { numberFormatter } = useFormat();
|
||||
|
||||
|
@ -138,7 +138,8 @@ export function Sidebar() {
|
|||
<div>
|
||||
<p>{achievement.displayName}</p>
|
||||
<small>
|
||||
{achievement.unlockTime && format(achievement.unlockTime)}
|
||||
{achievement.unlockTime &&
|
||||
formatDateTime(achievement.unlockTime)}
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -176,7 +177,8 @@ export function Sidebar() {
|
|||
<div>
|
||||
<p>{achievement.displayName}</p>
|
||||
<small>
|
||||
{achievement.unlockTime && format(achievement.unlockTime)}
|
||||
{achievement.unlockTime &&
|
||||
formatDateTime(achievement.unlockTime)}
|
||||
</small>
|
||||
</div>
|
||||
</Link>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue