Skip to content

Commit 8d15222

Browse files
authored
Add possibility to change timestamp format (#3201)
* add global setting to change between local and utc time * add control to change time format on detailed views * tweaks * adapt uptime graphs to work with utc time from settings * fix tests * add maxDiffPixels for SearchResults test * fix test
1 parent 4fc7050 commit 8d15222

File tree

164 files changed

+392
-206
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

164 files changed

+392
-206
lines changed

.vscode/tasks.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@
341341
"localhost",
342342
"arbitrum",
343343
"arbitrum_sepolia",
344+
"arbitrum_nova",
344345
"base",
345346
"blackfort_testnet",
346347
"celo",

configs/envs/.env.mega_eth

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ NEXT_PUBLIC_MARKETPLACE_CATEGORIES_URL=https://raw.githubusercontent.com/blocksc
3333
NEXT_PUBLIC_MARKETPLACE_ENABLED=true
3434
NEXT_PUBLIC_MARKETPLACE_SUBMIT_FORM=https://airtable.com/appiy5yijZpMMSKjT/shr6uMGPKjj1DK7NL
3535
NEXT_PUBLIC_MARKETPLACE_SUGGEST_IDEAS_FORM=https://airtable.com/appiy5yijZpMMSKjT/pag3t82DUCyhGRZZO/form
36+
NEXT_PUBLIC_MEGA_ETH_SOCKET_URL_METRICS=wss://testnetv2-dashboard.megaeth.com/metrics
37+
NEXT_PUBLIC_MEGA_ETH_SOCKET_URL_RPC=wss://megaeth-testnet-v2.blockscout.com/api/v2/proxy/3rdparty/ws_megaeth_testnet_2
3638
NEXT_PUBLIC_METADATA_SERVICE_API_HOST=https://metadata.services.blockscout.com
3739
NEXT_PUBLIC_MIXPANEL_CONFIG_OVERRIDES={"record_sessions_percent": 0.5,"record_heatmap_data": true}
3840
NEXT_PUBLIC_NETWORK_CURRENCY_DECIMALS=18

lib/contexts/settings.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ interface TSettingsContext {
1616
toggleAddressFormat: () => void;
1717
timeFormat: TimeFormat;
1818
toggleTimeFormat: () => void;
19+
isLocalTime: boolean;
20+
toggleIsLocalTime: () => void;
1921
}
2022

2123
export const SettingsContext = React.createContext<TSettingsContext | null>(null);
@@ -32,6 +34,10 @@ export function SettingsContextProvider({ children }: SettingsProviderProps) {
3234
cookies.get(cookies.NAMES.TIME_FORMAT, appCookies) as TimeFormat || 'relative',
3335
);
3436

37+
const [ isLocalTime, setIsLocalTime ] = React.useState<boolean>(
38+
(cookies.get(cookies.NAMES.LOCAL_TIME, appCookies) ?? 'true') === 'true',
39+
);
40+
3541
const toggleAddressFormat = React.useCallback(() => {
3642
setAddressFormat(prev => {
3743
const nextValue = prev === 'base16' ? 'bech32' : 'base16';
@@ -48,14 +54,24 @@ export function SettingsContextProvider({ children }: SettingsProviderProps) {
4854
});
4955
}, []);
5056

57+
const toggleIsLocalTime = React.useCallback(() => {
58+
setIsLocalTime(prev => {
59+
const nextValue = !prev;
60+
cookies.set(cookies.NAMES.LOCAL_TIME, nextValue ? 'true' : 'false');
61+
return nextValue;
62+
});
63+
}, []);
64+
5165
const value = React.useMemo(() => {
5266
return {
5367
addressFormat,
5468
toggleAddressFormat,
5569
timeFormat,
5670
toggleTimeFormat,
71+
isLocalTime,
72+
toggleIsLocalTime,
5773
};
58-
}, [ addressFormat, toggleAddressFormat, timeFormat, toggleTimeFormat ]);
74+
}, [ addressFormat, toggleAddressFormat, timeFormat, toggleTimeFormat, isLocalTime, toggleIsLocalTime ]);
5975

6076
return (
6177
<SettingsContext.Provider value={ value }>

lib/cookies.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export enum NAMES {
1414
ADDRESS_IDENTICON_TYPE = 'address_identicon_type',
1515
ADDRESS_FORMAT = 'address_format',
1616
TIME_FORMAT = 'time_format',
17+
LOCAL_TIME = 'local_time',
1718
INDEXING_ALERT = 'indexing_alert',
1819
ADBLOCK_DETECTED = 'adblock_detected',
1920
MIXPANEL_DEBUG = '_mixpanel_debug',

lib/date/dayjs.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import localizedFormat from 'dayjs/plugin/localizedFormat';
55
import minMax from 'dayjs/plugin/minMax';
66
import relativeTime from 'dayjs/plugin/relativeTime';
77
import updateLocale from 'dayjs/plugin/updateLocale';
8+
import utc from 'dayjs/plugin/utc';
89
import weekOfYear from 'dayjs/plugin/weekOfYear';
910

1011
import { nbsp } from 'toolkit/utils/htmlEntities';
@@ -34,6 +35,7 @@ dayjs.extend(localizedFormat);
3435
dayjs.extend(duration);
3536
dayjs.extend(weekOfYear);
3637
dayjs.extend(minMax);
38+
dayjs.extend(utc);
3739

3840
dayjs.updateLocale('en', {
3941
formats: {
@@ -63,3 +65,8 @@ dayjs.updateLocale('en', {
6365
dayjs.locale('en');
6466

6567
export default dayjs;
68+
69+
export const FORMATS = {
70+
// the "lll" format with seconds
71+
lll_s: 'MMM D, YYYY h:mm:ss A',
72+
};
567 Bytes
Loading
-846 Bytes
Loading
-750 Bytes
Loading
-801 Bytes
Loading
-763 Bytes
Loading

0 commit comments

Comments
 (0)