refactor(utils): Update date formatters to control time visibility
The `unixToDate` and `msToDate` utility functions have been updated to provide more control over the output format. They now accept an object with a `hasTime` boolean property, allowing the caller to specify whether the time should be included in the formatted date string. This change was implemented to hide the time portion of the `seen_at` field on the notification details page, displaying only the date. All existing calls to these functions across the application have been updated to use the new signature.
This commit is contained in:
+8
-2
@@ -1,6 +1,12 @@
|
||||
import * as moment from "moment";
|
||||
export const unixToDate = (unix: number) => {
|
||||
return moment.unix(unix).format("YYYY/MM/DD HH:MM");
|
||||
export const unixToDate = ({
|
||||
hasTime = false,
|
||||
unix,
|
||||
}: {
|
||||
unix: number;
|
||||
hasTime?: boolean;
|
||||
}) => {
|
||||
return moment.unix(unix).format(`YYYY/MM/DD ${hasTime && "HH:MM"}`);
|
||||
};
|
||||
export const msToDate = (ms: number) => {
|
||||
return moment.default(ms).format("YYYY/MM/DD");
|
||||
|
||||
Reference in New Issue
Block a user