Return the jsonLD version of a calendar.
511488
public function toJsonLd()
    {
        $jsonLd = [];

        $jsonLd['calendarType'] = $this->getType()->toNative();
        // All calendar types allow startDate (and endDate).
        // One timestamp - full day.
        // One timestamp - start hour.
        // One timestamp - start and end hour.
        empty($this->startDate) ?: $jsonLd['startDate'] = $this->getStartDate()->format(DateTime::ATOM);
        empty($this->endDate) ?: $jsonLd['endDate'] = $this->getEndDate()->format(DateTime::ATOM);


        $timestamps = $this->getTimestamps();
        if (!empty($timestamps)) {
            $jsonLd['subEvent'] = array();
            foreach ($timestamps as $timestamp) {
                $jsonLd['subEvent'][] = array(
                  '@type' => 'Event',
                  'startDate' => $timestamp->getStartDate()->format(DateTime::ATOM),
                  'endDate' => $timestamp->getEndDate()->format(DateTime::ATOM),
                );
            }
        }

        // Period.
        // Period with openingtimes.
        // Permanent - "altijd open".
        // Permanent - with openingtimes
        $openingHours = $this->getOpeningHours();
        if (!empty($openingHours)) {
            $jsonLd['openingHours'] = array();
            foreach ($openingHours as $openingHour) {
                $jsonLd['openingHours'][] = $openingHour->serialize();
            }
        }

        return $jsonLd;
    }
1021777
public static CharSequence getJSDate(Calendar calendar)
	{
		StringBuilder dateJavascript = new StringBuilder();
		dateJavascript.append("new Date(");
		dateJavascript.append(calendar.get(Calendar.YEAR)).append(',');
		dateJavascript.append(calendar.get(Calendar.MONTH)).append(',');
		dateJavascript.append(calendar.get(Calendar.DAY_OF_MONTH)).append(',');
		dateJavascript.append(calendar.get(Calendar.HOUR_OF_DAY)).append(',');
		dateJavascript.append(calendar.get(Calendar.MINUTE)).append(',');
		dateJavascript.append(calendar.get(Calendar.SECOND)).append(',');
		dateJavascript.append(calendar.get(Calendar.MILLISECOND));
		dateJavascript.append(')');

		return dateJavascript.toString();
	}
667077
def eidos_process_jsonld():
    """"""
    if request.method == 'OPTIONS':
        return {}
    response = request.body.read().decode('utf-8')
    body = json.loads(response)
    eidos_json = body.get('jsonld')
    ep = eidos.process_json_str(eidos_json)
    return _stmts_from_proc(ep)
587673
def infer_calendar_name(dates):
    """"""
    if np.asarray(dates).dtype == 'datetime64[ns]':
        return 'proleptic_gregorian'
    else:
        return np.asarray(dates).ravel()[0].calendar
156560
private Variants parseEras(JsonObject calendar) {
    JsonObject node = resolve(calendar, "eras");

    JsonObject abbr = resolve(node, "eraAbbr");
    JsonObject narrow = resolve(node, "eraNarrow");
    JsonObject wide = resolve(node, "eraNames");

    return new Variants(
        new String[] { string(abbr, "0"), string(abbr, "1") },
        new String[] { string(narrow, "0"), string(narrow, "1") },
        new String[] { },
        new String[] { string(wide, "0"), string(wide, "1") });
  }
430675
def for_json(self):
        """"""
        value = super(DatetimeField, self).for_json()

        # Order of instance checks matters for proper inheritance checks
        if isinstance(value, pendulum.Interval):
            return value.in_seconds() * 1000
        if isinstance(value, datetime):
            return self.format_datetime(value)
        if isinstance(value, pendulum.Time):
            return str(value)
        if isinstance(value, pendulum.Date):
            return value.to_date_string()
1144485
private static Calendar toCalendar(Date self) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(self);
        return cal;
    }
540471
public static String toJson(Calendar cal) {
        if (cal == null) {
            return NULL_VALUE;
        }

        CharBuf buffer = CharBuf.create(26);
        writeDate(cal.getTime(), buffer);

        return buffer.toString();
    }
1028844
private List<Skeleton> parseDateTimeSkeletons(JsonObject calendar) {
    JsonObject node = resolve(calendar, "dateTimeFormats", "availableFormats");
    List<Skeleton> value = new ArrayList<>();
    for (String key : objectKeys(node)) {
      value.add(new Skeleton(key, string(node, key)));
    }
    return value;
  }
519794
def get(self, request):
        """"""
        # Heavily inspired by https://djangosnippets.org/snippets/2223/ and
        # the icalendar documentation
        calendar = Calendar()
        site = get_current_site(request)
        calendar.add('prodid', '-//%s Schedule//%s//' % (site.name, site.domain))
        calendar.add('version', '2.0')

        # Since we don't need to format anything here, we can just use a list
        # of schedule items
        for item in ScheduleItem.objects.all():
            sched_event = Event()
            sched_event.add('dtstamp', item.last_updated)
            sched_event.add('summary', item.get_title())
            sched_event.add('location', item.venue.name)
            sched_event.add('dtstart', item.get_start_datetime())
            sched_event.add('duration', datetime.timedelta(minutes=item.get_duration_minutes()))
            sched_event.add('class', 'PUBLIC')
            sched_event.add('uid', '%s@%s' % (item.pk, site.domain))
            calendar.add_component(sched_event)
        response = HttpResponse(calendar.to_ical(), content_type="text/calendar")
        response['Content-Disposition'] = 'attachment; filename=schedule.ics'
        return response
1013130
def _context_json(name):
    """"""
    from renku.models import provenance

    cls = getattr(provenance, name)
    return {
        '@context': cls._jsonld_context,
        '@type': cls._jsonld_type,
    }
258854
def get_calendar(self, language_abbr=None):
        """"""
        if language_abbr:
            if not self._is_current_language(language_abbr):
                self._switch_language(language_abbr)
            return self.user_data.language_data[language_abbr]['calendar']
        else:
            return self.user_data.calendar
1103393
def _calendar_json_for_occurrence(self, occurrence):
        
        # Slugify the plugin's verbose name for use as a class name.
        if occurrence.is_all_day:
            start = occurrence.start
            # `end` is exclusive according to the doc in
            # http://fullcalendar.io/docs/event_data/Event_Object/, so
            # we need to add 1 day to ``end`` to have the end date
            # included in the calendar.
            end = occurrence.start + timedelta(days=1)
        else:
            start = djtz.localize(occurrence.start)
            end = djtz.localize(occurrence.end)
        if occurrence.is_cancelled and occurrence.cancel_reason:
            title = u"{0} [{1}]".format(
                occurrence.event.title, occurrence.cancel_reason)
        else:
            title = occurrence.event.title

        if occurrence.event.primary_type:
            color = occurrence.event.primary_type.color
        else:
            color = "#cccccc"
        return {
            'title': title,
            'allDay': occurrence.is_all_day or occurrence.event.contained_events.exists(),
            'start': start,
            'end': end,
            'url': reverse('admin:icekit_events_eventbase_change',
                           args=[occurrence.event.pk]),
            'className': self._calendar_classes_for_occurrence(occurrence),
            'backgroundColor': color,
        }
1353086
def date_json(self):
        
        if self.date:
            return json.dumps(self.date.isoformat(), ensure_ascii=False)
777341
def dict_jsonp(param):
    """"""
    if not isinstance(param, dict):
        param = dict(param)
    return jsonp(param)
1216903
def json(self, var, default=NOTSET, force=True):
        """"""
        return self._get(var, default=default, cast=json.loads, force=force)
288128
def get_date_or_404(year, month, day):
    """"""
    try:
        return datetime.date(int(year), int(month), int(day))
    except ValueError:
        raise Http404