prints a date-object
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)
186066
def date(self) -> Optional[DateHeader]:
        """"""
        try:
            return cast(DateHeader, self[b'date'][0])
        except (KeyError, IndexError):
            return None
1340455
def string_to_date(value):
    
    if isinstance(value, datetime.date):
        return value

    return dateutil.parser.parse(value).date()
516584
private static Date getDateOrNull(JSONObject obj, String field)
			throws JSONException {
		String dateStr = JsonInput.getStringOrNull(obj, field);
		if (dateStr == null)
			return null;
		try {
			if (dateStr.length() >= 5 && dateStr.charAt(4) == '/') {
				return RedmineDateUtils.FULL_DATE_FORMAT.get().parse(dateStr);
			}
			if (dateStr.endsWith("Z")) {
				dateStr = dateStr.substring(0, dateStr.length() - 1)
						+ "GMT-00:00";
			} else {
				final int inset = 6;
				if (dateStr.length() <= inset)
					throw new JSONException("Bad date value " + dateStr);
				String s0 = dateStr.substring(0, dateStr.length() - inset);
				String s1 = dateStr.substring(dateStr.length() - inset,
						dateStr.length());
				dateStr = s0 + "GMT" + s1;
			}
			return RedmineDateUtils.FULL_DATE_FORMAT_V2.get().parse(dateStr);
		} catch (ParseException e) {
			throw new JSONException("Bad date value " + dateStr);
		}
	}
93327
def _get_date_type(date):
        
        if isinstance(date, str):
            return 'str'

        if isinstance(date, datetime.date):
            return 'date'

        if isinstance(date, int):
            return 'int'

        raise ValueError('Unexpected type {0!s}'.format(date.__class__))
610822
def date(value):
    
    if isinstance(value, str):
        value = to_date(value)
    return literal(value, type=dt.date)
422864
def dateDict(date, prefix = ""):
    """"""
    res = {}

    res[prefix+"a"] = date.strftime("%a")
    res[prefix+"A"] = date.strftime("%A")
    res[prefix+"b"] = date.strftime("%b")
    res[prefix+"B"] = date.strftime("%B")
    res[prefix+"c"] = date.strftime("%c")
    res[prefix+"d"] = date.strftime("%d")
    res[prefix+"H"] = date.strftime("%H")
    res[prefix+"I"] = date.strftime("%I")
    res[prefix+"j"] = date.strftime("%j")
    res[prefix+"m"] = date.strftime("%m")
    res[prefix+"M"] = date.strftime("%M")
    res[prefix+"p"] = date.strftime("%p")
    res[prefix+"S"] = date.strftime("%S")
    res[prefix+"U"] = date.strftime("%U")
    res[prefix+"w"] = date.strftime("%w")
    res[prefix+"W"] = date.strftime("%W")
    res[prefix+"x"] = date.strftime("%x")
    res[prefix+"X"] = date.strftime("%X")
    res[prefix+"y"] = date.strftime("%y")
    res[prefix+"Y"] = date.strftime("%Y")
    res[prefix+"Z"] = date.strftime("%Z")

    for i, value in res.items():
        res[i] = locale_to_utf8(value)

    return res
1324124
public void printDate(WriteStreamOld os)
    throws IOException
  {
    os.print(DAY_NAMES[(int) (_dayOfEpoch % 7 + 11) % 7]);
    os.write(',');
    os.write(' ');
    os.print((_dayOfMonth + 1) / 10);
    os.print((_dayOfMonth + 1) % 10);
    os.write(' ');
    os.print(MONTH_NAMES[(int) _month]);
    os.write(' ');
    os.print(_year);
    os.write(' ');
    os.print((_timeOfDay / 36000000) % 10);
    os.print((_timeOfDay / 3600000) % 10);
    os.write(':');
    os.print((_timeOfDay / 600000) % 6);
    os.print((_timeOfDay / 60000) % 10);
    os.write(':');
    os.print((_timeOfDay / 10000) % 6);
    os.print((_timeOfDay / 1000) % 10);

    if (_zoneName == null) {
      os.print(" GMT");
      return;
    }

    long offset = _zoneOffset;

    if (offset < 0) {
      os.write(' ');
      os.write('-');
      offset = - offset;
    } else {
      os.write(' ');
      os.write('+');
    }

    os.print((offset / 36000000) % 10);
    os.print((offset / 3600000) % 10);
    os.print((offset / 600000) % 6);
    os.print((offset / 60000) % 10);

    os.write(' ');
    os.write('(');
    os.print(_zoneName);
    os.write(')');
  }
605125
def serialize_date(attr, **kwargs):
        
        if isinstance(attr, str):
            attr = isodate.parse_date(attr)
        t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day)
        return t
1124838
def _format_date(self, obj) -> str:
        
        if obj is None:
            return ''
        if isinstance(obj, datetime):
            obj = obj.date()
        return date_format(obj, 'SHORT_DATE_FORMAT')
133276
protected static String prettyPrint(Object obj){
		StringBuilder sb = new StringBuilder();
		if (obj == null){
			sb.append("NULL");
		} else 	if (obj instanceof Blob){
			sb.append(formatLogParam((Blob)obj));
		} else if (obj instanceof Clob){
			sb.append(formatLogParam((Clob)obj));
		} else if (obj instanceof Ref){
			sb.append(formatLogParam((Ref)obj));
		} else if (obj instanceof Array){
			sb.append(formatLogParam((Array)obj));
		} else if (obj instanceof String || obj instanceof Date){
			sb.append("'" + obj.toString()+"'");
		} else {
			sb.append(obj.toString());
		}
		return sb.toString();
	}
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))
268749
def date(date):
    
    date = date.value
    return (datetime.strptime(date[:-5], '%Y-%m-%dT%H:%M:%S')
            if len(date) == 24
            else datetime.strptime(date, '%Y%m%dT%H:%M:%S'))
219135
def format_date_argument(date_element):
    
    if not isinstance(date_element, (datetime.datetime, datetime.date)):
        # TODO:
        if "T" in date_element:
            _date = datetime.datetime.strptime(date_element, "%Y-%m-%dT%H:%M:%S")
        else:
            _date = datetime.datetime.strptime(date_element, "%Y-%m-%d").date()
    else:
        _date = date_element
    return _date.isoformat()
843949
public void printDate(CharBuffer cb)
  {
    cb.append(DAY_NAMES[(int) (_dayOfEpoch % 7 + 11) % 7]);
    cb.append(", ");
    cb.append((_dayOfMonth + 1) / 10);
    cb.append((_dayOfMonth + 1) % 10);
    cb.append(" ");
    cb.append(MONTH_NAMES[(int) _month]);
    cb.append(" ");
    cb.append(_year);
    cb.append(" ");
    cb.append((_timeOfDay / 36000000L) % 10);
    cb.append((_timeOfDay / 3600000L) % 10);
    cb.append(":");
    cb.append((_timeOfDay / 600000L) % 6);
    cb.append((_timeOfDay / 60000L) % 10);
    cb.append(":");
    cb.append((_timeOfDay / 10000L) % 6);
    cb.append((_timeOfDay / 1000L) % 10);

    if (_zoneName == null || _zoneName.equals("GMT")) {
      cb.append(" GMT");
      return;
    }

    long offset = _zoneOffset;

    if (offset < 0) {
      cb.append(" -");
      offset = - offset;
    } else
      cb.append(" +");

    cb.append((offset / 36000000) % 10);
    cb.append((offset / 3600000) % 10);
    cb.append((offset / 600000) % 6);
    cb.append((offset / 60000) % 10);

    cb.append(" (");
    cb.append(_zoneName);
    cb.append(")");
  }
665813
@Override
	public String asString(Object object) {
		// at this point object is a Date

		Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
		calendar.setTime((Date) object);

		StringBuilder builder = new StringBuilder();

		int year = calendar.get(Calendar.YEAR);
		if (calendar.get(Calendar.ERA) == 0) {
			// https://en.wikipedia.org/wiki/ISO_8601
			// by convention 1 BC is labeled +0000, 2 BC is labeled −0001, ...

			if (year > 1) {
				builder.append('-');
			}
			--year;
		}

		builder.append(String.format("%04d", year));
		builder.append('-');
		builder.append(String.format("%02d", calendar.get(Calendar.MONTH) + 1));
		builder.append('-');
		builder.append(String.format("%02d", calendar.get(Calendar.DATE)));
		builder.append('T');
		builder.append(String.format("%02d", calendar.get(Calendar.HOUR_OF_DAY)));
		builder.append(':');
		builder.append(String.format("%02d", calendar.get(Calendar.MINUTE)));
		builder.append(':');
		builder.append(String.format("%02d", calendar.get(Calendar.SECOND)));
		builder.append('Z');

		return builder.toString();
	}
78414
def date(self, date):
        """"""
        self._occurrence_data['date'] = self._utils.format_datetime(
            date, date_format='%Y-%m-%dT%H:%M:%SZ'
        )