-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Change date format to meet the national standard (GB/T 7408-2005) * Improve `ordinalNumber` function behavior * Add prefix in `formatRelative` depending on if it's a current week or not
- Loading branch information
Showing
16 changed files
with
196 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,4 +36,4 @@ var formatLong = { | |
}) | ||
} | ||
|
||
export default formatLong | ||
export default formatLong |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,29 @@ | ||
import isSameUTCWeek from '../../../../_lib/isSameUTCWeek/index.js' | ||
|
||
function checkWeek(_date, _baseDate, _options, baseFormat) { | ||
if (isSameUTCWeek(_date, _baseDate, _options)) { | ||
return baseFormat // in same week | ||
} else if (_date.getTime() > _baseDate.getTime()) { | ||
return "'下个'" + baseFormat // in next week | ||
} | ||
return "'上个'" + baseFormat // in last week | ||
} | ||
|
||
var formatRelativeLocale = { | ||
lastWeek: "'上个' eeee p", | ||
lastWeek: checkWeek, // days before yesterday, maybe in this week or last week | ||
yesterday: "'昨天' p", | ||
today: "'今天' p", | ||
tomorrow: "'明天' p", | ||
nextWeek: "'下个' eeee p", | ||
other: 'P' | ||
nextWeek: checkWeek, // days after tomorrow, maybe in this week or next week | ||
other: 'PP p' | ||
} | ||
|
||
export default function formatRelative(token, _date, _baseDate, _options) { | ||
return formatRelativeLocale[token] | ||
var format = formatRelativeLocale[token] | ||
|
||
if (typeof format === 'function') { | ||
return format(_date, _baseDate, _options, 'eeee p') | ||
} | ||
|
||
return format | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.