Generate a Scheduling Block data object.

    Args:
        date (datetime.datetime): UTC date of the SBI
        project (str): Project Name
        programme_block (str): Programme

    Returns:
        str, Scheduling Block Instance (SBI) ID.
340741
def generate_sb(date: datetime.datetime, project: str,
                programme_block: str) -> dict:
    
    date = date.strftime('%Y%m%d')
    instance_id = randint(0, 9999)
    sb_id = 'SB-{}-{}-{:04d}'.format(date, project, instance_id)
    return dict(id=sb_id, project=project, programme_block=programme_block)
16873
def _scheduling_block_config(num_blocks=5, start_sbi_id=0, start_pb_id=0,
                             project='sip'):
    """"""
    pb_id = start_pb_id
    for sb_id, sbi_id in _scheduling_block_ids(num_blocks, start_sbi_id,
                                               project):
        sub_array_id = 'subarray-{:02d}'.format(random.choice(range(5)))
        config = dict(id=sbi_id,
                      sched_block_id=sb_id,
                      sub_array_id=sub_array_id,
                      processing_blocks=_generate_processing_blocks(pb_id))
        pb_id += len(config['processing_blocks'])
        yield config
1055556
public static DateTime date(Date date) {
		if (date instanceof DateTime) {
			return (DateTime) date;
		}
		return dateNew(date);
	}
1172656
private String computeProjectName(String rootPath, Date date) {

        // create the temporary project, which is deleted after publishing
        // the publish scheduled date in project name
        String dateTime = CmsDateUtil.getDateTime(date, DateFormat.SHORT, getLocale());
        // the resource name to publish scheduled
        String projectName = CmsVaadinUtils.getMessageText(
            Messages.GUI_PUBLISH_SCHEDULED_PROJECT_NAME_2,
            rootPath,
            dateTime);
        // the HTML encoding for slashes is necessary because of the slashes in english date time format
        // in project names slahes are not allowed, because these are separators for organizaional units
        projectName = projectName.replace("/", "&#47;");
        while (projectName.length() > 190) {
            rootPath = "..." + rootPath.substring(5, rootPath.length());
            projectName = computeProjectName(rootPath, date);
        }
        return projectName;
    }
363673
public static void scheduleAzkabanProject(String sessionId, String azkabanProjectId,
      AzkabanProjectConfig azkabanProjectConfig)
      throws IOException {
    Map<String, String> params = Maps.newHashMap();
    params.put("ajax", "scheduleFlow");
    params.put("projectName", azkabanProjectConfig.getAzkabanProjectName());
    params.put("flow", azkabanProjectConfig.getAzkabanProjectFlowName());
    params.put("projectId", azkabanProjectId);
    params.put("scheduleTime", getScheduledTimeInAzkabanFormat(LOW_NETWORK_TRAFFIC_BEGIN_HOUR,
        LOW_NETWORK_TRAFFIC_END_HOUR, JOB_START_DELAY_MINUTES));
    params.put("scheduleDate", getScheduledDateInAzkabanFormat());
    params.put("is_recurring", "off");

    // Run once OR push down schedule (TODO: Enable when push down is finalized)
    //    if (azkabanProjectConfig.isScheduled()) {
    //      params.put("is_recurring", "on");
    //      params.put("period", "1d");
    //    } else {
    //      params.put("is_recurring", "off");
    //    }

    executePostRequest(preparePostRequest(azkabanProjectConfig.getAzkabanServerUrl() + "/schedule", sessionId, params));
  }
124755
def _cache_get(self, date):
        
        if date in self.cache_data:
            logger.debug('Using class-cached data for date %s',
                         date.strftime('%Y-%m-%d'))
            return self.cache_data[date]
        logger.debug('Getting data from cache for date %s',
                     date.strftime('%Y-%m-%d'))
        data = self.cache.get(self.project_name, date)
        self.cache_data[date] = data
        return data
115071
def build_date(self):
        
        # pylint: disable=len-as-condition
        if len(self.dutinformation) > 0 and (self.dutinformation.get(0).build is not None):
            return self.dutinformation.get(0).build.date
        return None
320353
def _build_date(date, kwargs):
    
    if date is None:
        if not kwargs:
            raise ValueError('Must pass a date or kwargs')
        else:
            return datetime.date(**kwargs)

    elif kwargs:
        raise ValueError('Cannot pass kwargs and a date')
    else:
        return date
920987
def date(self):
        
        if self._date:
            return self._date
        return datetime.datetime.now().strftime('%Y-%m-%d')
934076
public ScheduleDescriptor generateScheduleDescriptor(LocalDate startDate, LocalDate endDate) {
		return new ScheduleDescriptor(startDate, endDate, getFrequency(), getDaycountConvention(), getShortPeriodConvention(), getDateRollConvention(),
				getBusinessdayCalendar(), getFixingOffsetDays(), getPaymentOffsetDays(), isUseEndOfMonth());
	}
555898
def datetime(self):
        
        date_string = '%s %s %s' % (self._day,
                                    self._date,
                                    self._year)
        return datetime.strptime(date_string, '%a %B %d %Y')
214333
def scheduling_block_instances(self):
        """"""
        # TODO(BMo) change this to a pipe?
        sbi_list = SchedulingBlockInstanceList()
        return json.dumps(dict(active=sbi_list.active,
                               completed=sbi_list.completed,
                               aborted=sbi_list.aborted))
1130145
def date(ctx, year, month, day):
    
    return _date(conversions.to_integer(year, ctx), conversions.to_integer(month, ctx), conversions.to_integer(day, ctx))
321741
def delete_scheduling_block(block_id):
    """"""
    DB.delete('scheduling_block/{}'.format(block_id))

    # Add a event to the scheduling block event list to notify
    # of a deleting a scheduling block from the db
    DB.rpush('scheduling_block_events',
             json.dumps(dict(type="deleted", id=block_id)))
1114961
def calendar_data(self, request):
        

        # mutable copy
        request.GET = request.GET.copy()

        if 'timezone' in request.GET:
            tz = djtz.get(request.GET.pop('timezone'))
        else:
            tz = get_current_timezone()

        if 'start' in request.GET:
            start_dt = self._parse_dt_from_request(request, 'start')
            if start_dt:
                start = djtz.localize(start_dt, tz)
            else:
                start = None
        else:
            start = None
        if 'end' in request.GET:
            end_dt = self._parse_dt_from_request(request, 'end')
            if end_dt:
                end = djtz.localize(end_dt, tz)
            else:
                end = None
        else:
            end = None

        # filter the qs like the changelist filters
        cl = ChangeList(request, self.model, self.list_display,
                        self.list_display_links, self.list_filter,
                        self.date_hierarchy, self.search_fields,
                        self.list_select_related, self.list_per_page,
                        self.list_max_show_all, self.list_editable, self)

        filtered_event_ids = cl.get_queryset(request).values_list('id', flat=True)
        all_occurrences = models.Occurrence.objects.filter(event__id__in=filtered_event_ids).overlapping(start, end)

        data = []
        for occurrence in all_occurrences.all():
            data.append(self._calendar_json_for_occurrence(occurrence))
        data = json.dumps(data, cls=DjangoJSONEncoder)
        return HttpResponse(content=data, content_type='application/json')
1203908
def date_cast(date):
    '''
    
    '''
    if date is None:
        return datetime.datetime.now()
    elif isinstance(date, datetime.datetime):
        return date

    # fuzzy date
    try:
        if isinstance(date, six.string_types):
            try:
                if HAS_TIMELIB:
                    # py3: yes, timelib.strtodatetime wants bytes, not str :/
                    return timelib.strtodatetime(
                        salt.utils.stringutils.to_bytes(date))
            except ValueError:
                pass

            # not parsed yet, obviously a timestamp?
            if date.isdigit():
                date = int(date)
            else:
                date = float(date)

        return datetime.datetime.fromtimestamp(date)
    except Exception:
        if HAS_TIMELIB:
            raise ValueError('Unable to parse {0}'.format(date))

        raise RuntimeError(
                'Unable to parse {0}. Consider installing timelib'.format(date))
270655
def _build_date_time_time_zone(self, date_time):
        
        timezone = date_time.tzinfo.zone if date_time.tzinfo is not None else None
        return {
            self._cc('dateTime'): date_time.strftime('%Y-%m-%dT%H:%M:%S'),
            self._cc('timeZone'): get_windows_tz(timezone or self.protocol.timezone)
        }