// Helper Functions
#let monthname(n, display: "short") = {
  n = int(n)
  let month = ""

  if n == 1 { month = "January" } else if n == 3 { month = "March" } else if n == 2 { month = "February" } else if (
    n == 4
  ) { month = "April" } else if n == 5 { month = "May" } else if n == 6 { month = "June" } else if n == 7 {
    month = "July"
  } else if n == 8 { month = "August" } else if n == 9 { month = "September" } else if n == 10 {
    month = "October"
  } else if n == 11 { month = "November" } else if n == 12 { month = "December" } else { month = none }
  if month != none {
    if display == "short" {
      month = month.slice(0, 3)
    } else {
      month
    }
  }
  month
}

#let strpdate(isodate) = {
  let date = ""
  if lower(isodate) == "incoming" {
    date = "Incoming"
  } else if lower(isodate) == "present" {
    date = "Present"
  } else {
    let year = int(isodate.slice(0, 4))
    let month = int(isodate.slice(5, 7))
    let day = int(isodate.slice(8, 10))
    let monthName = monthname(month, display: "short")
    date = datetime(year: year, month: month, day: day)
    date = monthName + " " + date.display("[year repr:full]")
  }
  return date
}

#let daterange(start, end) = {
  if start != none and end != none and start != "Incoming" [
    #start #sym.dash.en #end
  ]
  if start == "Incoming" and end != none [
    #start #end
  ]
  if start == none and end != none [
    #end
  ]
  if start != none and end == none [
    #start
  ]
}
