import { differenceInWeeks } from 'date-fns' ; function getCWKEpisodePath ( { seasonNumber , episodeNumber , slug , } ) { return [ '/chats' , seasonNumber . toString ( ) . padStart ( 2 , '0' ) , episodeNumber . toString ( ) . padStart ( 2 , '0' ) , slug , ] . filter ( Boolean ) . join ( '/' ) ; } function getFeaturedEpisode < EpisodeType > ( episodes ) { const weeksSinceMyBirthday = differenceInWeeks ( new Date ( ) , new Date ( '1988-10-18' ) ) ; const featured = episodes [ weeksSinceMyBirthday % episodes . length ] ; if ( ! featured ) { throw new Error ( `Could not find featured episode. This should be impossible. ${ weeksSinceMyBirthday } % ${ episodes . length } = ${ weeksSinceMyBirthday % episodes . length }` ) ; } return featured ; } export { getCWKEpisodePath , getFeaturedEpisode } ;