code: def dateint_to_weekday(dateint, first_day='Monday'):
      
      weekday_ix = dateint_to_datetime(dateint).weekday()
      return (weekday_ix - WEEKDAYS.index(first_day)) % 7
docs: Returns the weekday of the given dateint.
  
      Arguments
      ---------
      dateint : int
          An integer object decipting a specific calendaric day; e.g. 20161225.
      first_day : str, default 'Monday'
          The first day of the week.
  
      Returns
      -------
      int
          The weekday of the given dateint, when first day of the week = 0,
          last day of the week = 6.
  
      Example
      -------
      >>> dateint_to_weekday(20170213)
      0
      >>> dateint_to_weekday(20170212)
      6
      >>> dateint_to_weekday(20170214)
      1
      >>> dateint_to_weekday(20170212, 'Sunday)
      0
      >>> dateint_to_weekday(20170214, 'Sunday')
      2