src/tokenizer/time.js
function lastDayOfMonth(time) {
  let year = time.getUTCFullYear()
  let nextMonth = time.getUTCMonth() + 2
  if (nextMonth > 12) {
    year++
    nextMonth = 1
  }
  let nextMonthStr = String(nextMonth)
  if (nextMonthStr.length === 1) { nextMonthStr = '0' + nextMonthStr }
  let date = new Date(`${year}-${nextMonthStr}-01T00:00:00Z`)
  return (new Date(+date - 1000)).getUTCDate()
}
function lastDayOfMonth(time) {
  let year = time.getUTCFullYear()
  let nextMonth = time.getUTCMonth() + 2
  if (nextMonth > 12) {
    year++
    nextMonth = 1
  }
  let nextMonthStr = String(nextMonth)
  if (nextMonthStr.length === 1) { nextMonthStr = '0' + nextMonthStr }
  let date = new Date(`${year}-${nextMonthStr}-01T00:00:00Z`)
  return (new Date(+date - 1000)).getUTCDate()
}
function lastDayOfMonth ( time ) { let year = time . getUTCFullYear ( ) let nextMonth = time . getUTCMonth ( ) + 2 if ( nextMonth > 12 ) { year ++ nextMonth = 1 } let nextMonthStr = String ( nextMonth ) if ( nextMonthStr . length === 1 ) { nextMonthStr = '0' + nextMonthStr } let date = new Date ( ` ${ year } ${ nextMonthStr } ` ) return ( new Date ( + date - 1000 ) ) . getUTCDate ( ) }
Takes a Date, returns the date of the last day of the corresponding month. eg, 31.
Takes a Date returns the date of the last day of the corresponding month . eg 31 .