List of datetimes based on design day date and timestep.
176602
def _get_datetimes(self, timestep=1):
        """"""
        start_moy = DateTime(self._month, self._day_of_month).moy
        if timestep == 1:
            start_moy = start_moy + 30
        num_moys = 24 * timestep
        return tuple(
            DateTime.from_moy(start_moy + (i * (1 / timestep) * 60))
            for i in xrange(num_moys)
        )
1066723
def date_suggestions():
    
    # don't use strftime, prevent locales to kick in
    days_of_week = {
        0: "Monday",
        1: "Tuesday",
        2: "Wednesday",
        3: "Thursday",
        4: "Friday",
        5: "Saturday",
        6: "Sunday"
    }

    dates = [
        'today',
        'tomorrow',
    ]

    # show days of week up to next week
    dow = datetime.date.today().weekday()
    for i in range(dow + 2 % 7, dow + 7):
        dates.append(days_of_week[i % 7])

    # and some more relative days starting from next week
    dates += ["1w", "2w", "1m", "2m", "3m", "1y"]

    return dates
377555
private void readCalendars()
   {
      Table cal = m_tables.get("CAL");
      for (MapRow row : cal)
      {
         ProjectCalendar calendar = m_projectFile.addCalendar();
         m_calendarMap.put(row.getInteger("CALENDAR_ID"), calendar);
         Integer[] days =
         {
            row.getInteger("SUNDAY_HOURS"),
            row.getInteger("MONDAY_HOURS"),
            row.getInteger("TUESDAY_HOURS"),
            row.getInteger("WEDNESDAY_HOURS"),
            row.getInteger("THURSDAY_HOURS"),
            row.getInteger("FRIDAY_HOURS"),
            row.getInteger("SATURDAY_HOURS")
         };

         calendar.setName(row.getString("NAME"));
         readHours(calendar, Day.SUNDAY, days[0]);
         readHours(calendar, Day.MONDAY, days[1]);
         readHours(calendar, Day.TUESDAY, days[2]);
         readHours(calendar, Day.WEDNESDAY, days[3]);
         readHours(calendar, Day.THURSDAY, days[4]);
         readHours(calendar, Day.FRIDAY, days[5]);
         readHours(calendar, Day.SATURDAY, days[6]);

         int workingDaysPerWeek = 0;
         for (Day day : Day.values())
         {
            if (calendar.isWorkingDay(day))
            {
               ++workingDaysPerWeek;
            }
         }

         Integer workingHours = null;
         for (int index = 0; index < 7; index++)
         {
            if (days[index].intValue() != 0)
            {
               workingHours = days[index];
               break;
            }
         }

         if (workingHours != null)
         {
            int workingHoursPerDay = countHours(workingHours);
            int minutesPerDay = workingHoursPerDay * 60;
            int minutesPerWeek = minutesPerDay * workingDaysPerWeek;
            int minutesPerMonth = 4 * minutesPerWeek;
            int minutesPerYear = 52 * minutesPerWeek;

            calendar.setMinutesPerDay(Integer.valueOf(minutesPerDay));
            calendar.setMinutesPerWeek(Integer.valueOf(minutesPerWeek));
            calendar.setMinutesPerMonth(Integer.valueOf(minutesPerMonth));
            calendar.setMinutesPerYear(Integer.valueOf(minutesPerYear));
         }
      }
   }
656287
private String[] getDatePatterns(ProjectProperties properties)
   {
      String pattern = "";

      char datesep = properties.getDateSeparator();
      DateOrder dateOrder = properties.getDateOrder();

      switch (dateOrder)
      {
         case DMY:
         {
            pattern = "dd" + datesep + "MM" + datesep + "yy";
            break;
         }

         case MDY:
         {
            pattern = "MM" + datesep + "dd" + datesep + "yy";
            break;
         }

         case YMD:
         {
            pattern = "yy" + datesep + "MM" + datesep + "dd";
            break;
         }
      }

      return new String[]
      {
         pattern
      };
   }
1045962
def asdatetime(self, naive=True):
    
    args = list(self.timetuple()[0:6])+[self.microsecond]
    if not naive:
      args.append(self.tzinfo)
    return datetime.datetime(*args)
849792
def built_datetime(self):
        """"""
        from datetime import datetime
        try:
            return datetime.fromtimestamp(self.state.build_done)
        except TypeError:
            # build_done is null
            return None
687409
def timestamps(self):
        ''''''
        timestamps = set()
        for series in self.groups.itervalues():
            timestamps |= set(series.timestamps)
        return sorted(list(timestamps))
675298
def create_date_formats():
    """"""
    # European style:
    base_formats = ['%d %m %Y', '%d %m %y', '%Y %m %d']
    # US style:
    base_formats += ['%m %d %Y', '%m %d %y', '%Y %m %d']
    # Things with words in
    base_formats += ['%d %b %Y', '%d %B %Y']

    date_formats = []
    for separator in ('-', '.', '/', ' '):
        for date_format in base_formats:
            date_formats.append((date_format.replace(' ', separator)))

    datetime_formats = []
    time_formats = ('%H:%M%Z', '%H:%M:%S', '%H:%M:%S%Z', '%H:%M%z',
                    '%H:%M:%S%z')

    for date_format in date_formats:
        for time_format in time_formats:
            for separator in ('', 'T', ' '):
                datetime_formats.append(date_format + separator + time_format)

    return tuple(date_formats), tuple(datetime_formats)
962271
def _calc_daystamps(self, st_time, end_time):
        
        start_doy = sum(self._num_of_days_each_month[:st_time.month-1]) + st_time.day
        end_doy = sum(self._num_of_days_each_month[:end_time.month-1]) + end_time.day + 1
        return list(range(start_doy, end_doy))
1113120
def date_matches(self, timestamp):
        """"""
        if self.date is None:
            return False

        timestamp = datetime.fromtimestamp(float(timestamp), self.timezone)
        if self.date.date() == timestamp.date():
            return True

        return False
432752
def calculate_date_strings(self, mode, numDays):
        """"""

        yesterday = date.today() - timedelta(days=1)
        endday = datetime(yesterday.year, yesterday.month, yesterday.day, 23, 59, 59, 999)
        if mode:
            startday = yesterday - timedelta(days=numDays)
        else:
            # daily mode
            startday = yesterday

        return startday.isoformat(), endday.strftime('%Y-%m-%d %H:%M:%S.%f')
1152690
def _join_date_and_time(dates, times, joiner):
  
  return tuple("{}{}{}".format(d, joiner, t) for (d, t) in itertools.product(dates, times))
1052076
def _GetDateValuesWithEpoch(self, number_of_days, date_time_epoch):
    
    return self._GetDateValues(
        number_of_days, date_time_epoch.year, date_time_epoch.month,
        date_time_epoch.day_of_month)
181324
def print_datetime_object(dt):
    """"""
    print(dt)
    print('ctime  :', dt.ctime())
    print('tuple  :', dt.timetuple())
    print('ordinal:', dt.toordinal())
    print('Year   :', dt.year)
    print('Mon    :', dt.month)
    print('Day    :', dt.day)
28707
def strptime(date):
    """"""
    d = {
        'year': date[0:4],
        'month': date[5:7],
        'day': date[8:10],
        'hour': date[11:13],
        'minute': date[14:16],
        'second': date[17:],
    }

    d = dict((k, int(v)) for k, v in d.items())

    return datetime(**d)
717522
def _generate_time_steps(self, trajectory_list):
    """"""
    for time_step in env_problem.EnvProblem._generate_time_steps(
        self, trajectory_list):
      # Convert the rendered observations from numpy to png format.
      frame_np = np.array(time_step.pop(env_problem.OBSERVATION_FIELD))
      frame_np = frame_np.reshape(
          [self.frame_height, self.frame_width, self.num_channels])
      # TODO(msaffar) Add support for non RGB rendered environments
      frame = png.from_array(frame_np, "RGB", info={"bitdepth": 8})
      frame_buffer = six.BytesIO()
      frame.save(frame_buffer)

      # Put the encoded frame back.
      time_step[_IMAGE_ENCODED_FIELD] = [frame_buffer.getvalue()]
      time_step[_IMAGE_FORMAT_FIELD] = [_FORMAT]
      time_step[_IMAGE_HEIGHT_FIELD] = [self.frame_height]
      time_step[_IMAGE_WIDTH_FIELD] = [self.frame_width]

      # Add the frame number
      time_step[_FRAME_NUMBER_FIELD] = time_step[env_problem.TIMESTEP_FIELD]
      yield time_step
353961
def infos(self, typ, light=None, date=None):
        '''
        
        '''
        d = self._getDate(typ, light)
        if date is None:
            return [c[1] for c in d]
        # TODO: not struct time, but time in ms since epoch
        return _getFromDate(d, date)[1]