import _debug from 'debug' ; import { DateTime } from 'luxon' ; enum LUXON_DATE_FORMAT { YYYY_LL_DD = 'yyyy-LL-dd' , YYYY_LL = 'yyyy-LL' , YYYY_DOT_LL = 'yyyy. LL' , YYYY_DOT_LL_DOT_DD = 'yyyy. LL. dd' , KINDNESS_FULL = 'DDDD' , DURATION_KINDNESS = 'y년 M개월' , DURATION_KINDNESS_ONLY_MONTH = 'M개월' } function getFormattingDuration ( from , to = DateTime . local ( ) ) { const log = debug ( 'Util:getFormattingDuration' ) ; const diff = to . plus ( { month : 1 } ) . diff ( from ) ; log ( diff . milliseconds , diff . get ( 'years' ) ) ; const format = diff . milliseconds < 31536000000 ? LUXON_DATE_FORMAT . DURATION_KINDNESS_ONLY_MONTH : LUXON_DATE_FORMAT . DURATION_KINDNESS ; return diff . toFormat ( format ) ; } function debug ( channel ) { return _debug ( `yosume:${ channel }` ) ; } const Util = { LUXON_DATE_FORMAT , getFormattingDuration , debug , } ; export default Util ;