Skip to content

Commit

Permalink
fix(past-time-picker): Earliest in history feature (#2196)
Browse files Browse the repository at this point in the history
* fix(sinceRangePicker): change params

* fix: bug echo title

---------

Co-authored-by: vermilionAnd <[email protected]>
  • Loading branch information
zhuzilv and vermilionAnd authored Oct 10, 2023
1 parent 393a14b commit f3d8908
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
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

0 comments on commit f3d8908

Please sign in to comment.