Skip to content
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

fix(past-time-picker): Earliest in history feature #2196

Merged
merged 3 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 3 additions & 1 deletion src/past-time-picker/PastTimePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ const PastTimePicker = (props: PastTimePickerProps) => {
dayText,
timeRangeText,
earliestInHistory,
earliestInHistoryEcho,
} = {
...defaultLocale,
...locale,
Expand Down Expand Up @@ -119,12 +120,13 @@ const PastTimePicker = (props: PastTimePickerProps) => {
}
if (has(QUICK_MAPPING, time)) {
const [startTime, endTime] = parseQuickDate(time);
const showSinceZero = time === 'since:0' ? earliestInHistoryEcho : `${get(QUICK_MAPPING, time)}`;
return showAbsDate
? `${get(QUICK_MAPPING, time)} | ${parseFnsTimeZone(startTime, 'yyyy/MM/dd')}-${parseFnsTimeZone(
endTime,
'yyyy/MM/dd'
)}`
: `${get(QUICK_MAPPING, time)}`;
: showSinceZero;
}
const items = time.split(':');
const times = items[1].split(',').map((str) => parseInt(str, 10));
Expand Down
7 changes: 4 additions & 3 deletions src/static-past-time-picker/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import defaultLocaleText from './locales/zh-CN';
export const DATE_FORMAT = 'yyyy/MM/dd';

export const experimentalQuickOptions = (localeText: typeof defaultLocaleText) => [
{ value: 'hour:25,1', label: localeText.lastSomeHours?.(24) },
{ value: 'hour:73,1', label: localeText.lastSomeHours?.(72) },
{ value: 'hour:49,1', label: localeText.lastSomeHours?.(48) },
{ value: 'hour:25,1', label: localeText.lastSomeHours?.(24) },
{ value: 'hour:73,1', label: localeText.lastSomeHours?.(72) },
{ value: 'hour:49,1', label: localeText.lastSomeHours?.(48) },
];

export const QUICK_MAPPING = {
Expand All @@ -29,6 +29,7 @@ export const QUICK_MAPPING = {
'day:15,1': '过去 14 天',
'day:91,1': '过去 90 天',
'day:366,1': '过去 365 天',
'since:0': '历史最早',
};

export const END_DATE_MAPPING: { [key: string]: string } = {
Expand Down
1 change: 1 addition & 0 deletions src/static-past-time-picker/locales/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export default {
thisYearTextToYesterday: 'This year(to yesterday)',
lastYearText: 'Last Year',
earliestInHistory: 'Earliest in history',
earliestInHistoryEcho: 'Earliest in history to present',
lastSomeHours: (text: Key) => `Last ${text} hour(s)`,
last7DaysText: 'Previous 7 days',
last14DaysText: 'Previous 14 days',
Expand Down
1 change: 1 addition & 0 deletions src/static-past-time-picker/locales/zh-CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export default {
thisYearTextToYesterday: '今年(至昨日)',
lastYearText: '去年',
earliestInHistory: '历史最早',
earliestInHistoryEcho: '历史最早 至今日',
lastSomeHours: (text: Key) => `过去 ${text} 小时`,
last7DaysText: '过去7天',
last14DaysText: '过去14天',
Expand Down
Loading