import isSameUTCWeek from '../../../../_lib/isSameUTCWeek/index' ; import type { FormatRelativeFn , FormatRelativeFnOptions } from '../../../types' ; function checkWeek ( date , baseDate , options ? ) { const baseFormat = 'eeee p' ; if ( isSameUTCWeek ( date , baseDate , options ) ) { return baseFormat ; } else if ( date . getTime ( ) > baseDate . getTime ( ) ) { return "'下个'" + baseFormat ; } return "'上个'" + baseFormat ; } const formatRelativeLocale = { lastWeek : checkWeek , yesterday : "'昨天' p" , today : "'今天' p" , tomorrow : "'明天' p" , nextWeek : checkWeek , other : 'PP p' , } ; const formatRelative = ( token , date , baseDate , options ) => { const format = formatRelativeLocale [ token ] ; if ( typeof format === 'function' ) { return format ( date , baseDate , options ) ; } return format ; } ; export default formatRelative ;