Seed days of the week with ISO-8601 numeric code.
15713
protected function seedDays()
    {
        $this->output->info('### Seeding days###');
        //%u	ISO-8601 numeric representation of the day of the week	1 (for Monday) through 7 (for Sunday)
        $timestamp = strtotime('next Monday');
        $days = array();
        for ($i = 1; $i < 8; $i++) {
            $days[$i] = strftime('%A', $timestamp);
            $timestamp = strtotime('+1 day', $timestamp);
        }

        foreach ($days as $dayNumber => $day) {
            $this->output->info('### Seeding day: ' . $day . ' ###');
            $dayModel = Day::firstOrNew([
                'code' => $dayNumber,
                ]
            );
            $dayModel->name = $day;
            $dayModel->code = $dayNumber;
            $dayModel->lective = true;
            if ($dayNumber == 6 || $dayNumber == 7) {
                $dayModel->lective = false;
            }
            $dayModel->save();
        }
        $this->output->info('### END Seeding days###');
    }
310076
function d3_time_parseWeekday(date, string, i) {
  d3_time_weekdayRe.lastIndex = 0;
  var n = d3_time_weekdayRe.exec(string.substring(i, i + 10));
  return n ? i += n[0].length : -1;
}
599921
private void readNormalDay(ProjectCalendar calendar, Project.Calendars.Calendar.WeekDays.WeekDay weekDay)
   {
      int dayNumber = weekDay.getDayType().intValue();
      Day day = Day.getInstance(dayNumber);
      calendar.setWorkingDay(day, BooleanHelper.getBoolean(weekDay.isDayWorking()));
      ProjectCalendarHours hours = calendar.addCalendarHours(day);

      Project.Calendars.Calendar.WeekDays.WeekDay.WorkingTimes times = weekDay.getWorkingTimes();
      if (times != null)
      {
         for (Project.Calendars.Calendar.WeekDays.WeekDay.WorkingTimes.WorkingTime period : times.getWorkingTime())
         {
            Date startTime = period.getFromTime();
            Date endTime = period.getToTime();

            if (startTime != null && endTime != null)
            {
               if (startTime.getTime() >= endTime.getTime())
               {
                  endTime = DateHelper.addDays(endTime, 1);
               }

               hours.addRange(new DateRange(startTime, endTime));
            }
         }
      }
   }
1172754
private SortedSet<WeekDay> readWeekDays(JSONObject val) {

        try {
            JSONArray array = val.getJSONArray(JsonKey.PATTERN_WEEKDAYS);
            if (null != array) {
                SortedSet<WeekDay> result = new TreeSet<>();
                for (int i = 0; i < array.length(); i++) {
                    try {
                        result.add(WeekDay.valueOf(array.getString(i)));
                    } catch (JSONException | IllegalArgumentException e) {
                        LOG.error("Could not read weekday from JSON. Skipping that day.", e);
                    }
                }
                return result;
            }
        } catch (JSONException e) {
            LOG.debug("Could not read weekdays from JSON", e);
        }
        return new TreeSet<>();

    }
35306
private static int getWeekIndex(final Calendar cal) {
        final int val = cal.get(Calendar.DAY_OF_WEEK);
        switch(val) {
            case Calendar.SUNDAY:
                return 0;
            case Calendar.MONDAY:
                return 1;
            case Calendar.TUESDAY:
                return 2;
            case Calendar.WEDNESDAY:
                return 3;
            case Calendar.THURSDAY:
                return 4;
            case Calendar.FRIDAY:
                return 5;
            case Calendar.SATURDAY:
                return 6;
        }

        return 0;
    }
538767
def monthdayscalendar(cls, year, month):
        """"""
        weeks = []
        week = []
        for day in NepCal.itermonthdays(year, month):
            week.append(day)
            if len(week) == 7:
                weeks.append(week)
                week = []
        if len(week) > 0:
            weeks.append(week)
        return weeks
782045
function startOfIsoWeek (y, w) {
    const dow = isoDow(y, 1, 1);
    const startDay = dow > 4 ? 9 - dow : 2 - dow;
    const startDate = new Date(y, 0, startDay);
    return addDays(startDate, (w - 1) * 7);
}
297523
private void processWorkWeekDay(byte[] data, int offset, ProjectCalendarWeek week, Day day)
   {
      //System.out.println(ByteArrayHelper.hexdump(data, offset, 60, false));

      int dayType = MPPUtility.getShort(data, offset + 0);
      if (dayType == 1)
      {
         week.setWorkingDay(day, DayType.DEFAULT);
      }
      else
      {
         ProjectCalendarHours hours = week.addCalendarHours(day);
         int rangeCount = MPPUtility.getShort(data, offset + 2);
         if (rangeCount == 0)
         {
            week.setWorkingDay(day, DayType.NON_WORKING);
         }
         else
         {
            week.setWorkingDay(day, DayType.WORKING);
            Calendar cal = DateHelper.popCalendar();
            for (int index = 0; index < rangeCount; index++)
            {
               Date startTime = DateHelper.getCanonicalTime(MPPUtility.getTime(data, offset + 8 + (index * 2)));
               int durationInSeconds = MPPUtility.getInt(data, offset + 20 + (index * 4)) * 6;
               cal.setTime(startTime);
               cal.add(Calendar.SECOND, durationInSeconds);
               Date finishTime = DateHelper.getCanonicalTime(cal.getTime());
               hours.addRange(new DateRange(startTime, finishTime));
            }
            DateHelper.pushCalendar(cal);
         }
      }
   }
1174423
private int getDaysToNextMatch(WeekDay weekDay) {

        for (WeekDay wd : m_weekDays) {
            if (wd.compareTo(weekDay) > 0) {
                return wd.toInt() - weekDay.toInt();
            }
        }
        return (m_weekDays.iterator().next().toInt() + (m_interval * I_CmsSerialDateValue.NUM_OF_WEEKDAYS))
            - weekDay.toInt();
    }
1140111
function calculateDatePos(startDayOfMonth, day) {
	const start = startDayOfMonth - 1;
	day = day - 1;
	const weekDayIndex = (start + day) % WEEKDAYS;
	const weekIndex = Math.ceil((start + day + 1) / WEEKDAYS) - 1;
	return {
		weekIndex,
		weekDayIndex
	};
}
909246
private int matchDayPeriodString(String text, int start, String[] data, int dataLength,
            Output<DayPeriodRules.DayPeriod> dayPeriod)
    {
        int bestMatchLength = 0, bestMatch = -1;
        int matchLength = 0;
        for (int i = 0; i < dataLength; ++i) {
            // Only try matching if the string exists.
            if (data[i] != null) {
                int length = data[i].length();
                if (length > bestMatchLength &&
                        (matchLength = regionMatchesWithOptionalDot(text, start, data[i], length)) >= 0) {
                    bestMatch = i;
                    bestMatchLength = matchLength;
                }
            }
        }

        if (bestMatch >= 0) {
            dayPeriod.value = DayPeriodRules.DayPeriod.VALUES[bestMatch];
            return start + bestMatchLength;
        }

        return -start;
    }
913729
private void writeDayTypes(Calendars calendars)
   {
      DayTypes dayTypes = m_factory.createDayTypes();
      calendars.setDayTypes(dayTypes);
      List<DayType> typeList = dayTypes.getDayType();

      DayType dayType = m_factory.createDayType();
      typeList.add(dayType);
      dayType.setId("0");
      dayType.setName("Working");
      dayType.setDescription("A default working day");

      dayType = m_factory.createDayType();
      typeList.add(dayType);
      dayType.setId("1");
      dayType.setName("Nonworking");
      dayType.setDescription("A default non working day");

      dayType = m_factory.createDayType();
      typeList.add(dayType);
      dayType.setId("2");
      dayType.setName("Use base");
      dayType.setDescription("Use day from base calendar");
   }
539524
def W(self):
    ""
    # Algorithm from http://www.personal.ecu.edu/mccartyr/ISOwdALG.txt
    week_number = None
    jan1_weekday = self.data.replace(month=1, day=1).weekday() + 1
    weekday = self.data.weekday() + 1
    day_of_year = self.z()
    if day_of_year <= (8 - jan1_weekday) and jan1_weekday > 4:
      if jan1_weekday == 5 or (jan1_weekday == 6 and calendar.isleap(self.data.year-1)):
        week_number = 53
      else:
        week_number = 52
    else:
      if calendar.isleap(self.data.year):
        i = 366
      else:
        i = 365
      if (i - day_of_year) < (4 - weekday):
        week_number = 1
      else:
        j = day_of_year + (7 - weekday) + (jan1_weekday - 1)
        week_number = j // 7
        if jan1_weekday > 4:
          week_number -= 1
    return week_number
954579
private void readDay(ProjectCalendar calendar, Project.Calendars.Calendar.WeekDays.WeekDay day, boolean readExceptionsFromDays)
   {
      BigInteger dayType = day.getDayType();
      if (dayType != null)
      {
         if (dayType.intValue() == 0)
         {
            if (readExceptionsFromDays)
            {
               readExceptionDay(calendar, day);
            }
         }
         else
         {
            readNormalDay(calendar, day);
         }
      }
   }
546087
function configFromRFC2822(config) {
    var string, match, dayFormat,
        dateFormat, timeFormat, tzFormat;
    var timezones = {
        ' GMT': ' +0000',
        ' EDT': ' -0400',
        ' EST': ' -0500',
        ' CDT': ' -0500',
        ' CST': ' -0600',
        ' MDT': ' -0600',
        ' MST': ' -0700',
        ' PDT': ' -0700',
        ' PST': ' -0800'
    };
    var military = 'YXWVUTSRQPONZABCDEFGHIKLM';
    var timezone, timezoneIndex;

    string = config._i
        .replace(/\([^\)]*\)|[\n\t]/g, ' ') // Remove comments and folding whitespace
        .replace(/(\s\s+)/g, ' ') // Replace multiple-spaces with a single space
        .replace(/^\s|\s$/g, ''); // Remove leading and trailing spaces
    match = basicRfcRegex.exec(string);

    if (match) {
        dayFormat = match[1] ? 'ddd' + ((match[1].length === 5) ? ', ' : ' ') : '';
        dateFormat = 'D MMM ' + ((match[2].length > 10) ? 'YYYY ' : 'YY ');
        timeFormat = 'HH:mm' + (match[4] ? ':ss' : '');

        // TODO: Replace the vanilla JS Date object with an indepentent day-of-week check.
        if (match[1]) { // day of week given
            var momentDate = new Date(match[2]);
            var momentDay = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'][momentDate.getDay()];

            if (match[1].substr(0,3) !== momentDay) {
                getParsingFlags(config).weekdayMismatch = true;
                config._isValid = false;
                return;
            }
        }

        switch (match[5].length) {
            case 2: // military
                if (timezoneIndex === 0) {
                    timezone = ' +0000';
                } else {
                    timezoneIndex = military.indexOf(match[5][1].toUpperCase()) - 12;
                    timezone = ((timezoneIndex < 0) ? ' -' : ' +') +
                        (('' + timezoneIndex).replace(/^-?/, '0')).match(/..$/)[0] + '00';
                }
                break;
            case 4: // Zone
                timezone = timezones[match[5]];
                break;
            default: // UT or +/-9999
                timezone = timezones[' GMT'];
        }
        match[5] = timezone;
        config._i = match.splice(1).join('');
        tzFormat = ' ZZ';
        config._f = dayFormat + dateFormat + timeFormat + tzFormat;
        configFromStringAndFormat(config);
        getParsingFlags(config).rfc2822 = true;
    } else {
        config._isValid = false;
    }
}
607489
static void rollToNextWeekStart(DTBuilder builder, Weekday wkst) {
        DateValue bd = builder.toDate();
        builder.day += (7 - ((7 + (Weekday.valueOf(bd).javaDayNum
                - wkst.javaDayNum))
                % 7)) % 7;
        builder.normalize();
    }
583279
function getWeekNumber(day) {
  var date = clone(day);
  date.setHours(0, 0, 0);
  date.setDate(date.getDate() + 4 - (date.getDay() || 7));
  return Math.ceil(((date - new Date(date.getFullYear(), 0, 1)) / 8.64e7 + 1) / 7);
}