Lines Matching defs:offset
292 * work with the offset from that boundary to ordinal. Life is much
317 /* Now n is the (non-negative) offset, in days, from January 1 of
347 /* Now the year is correct, and n is the offset from January 1. We
1146 PyObject *offset;
1155 /* Create new timezone instance checking offset range. This
1157 that offset is a timedelta instance and name is either NULL
1160 create_timezone(PyObject *offset, PyObject *name)
1165 assert(offset != NULL);
1166 assert(PyDelta_Check(offset));
1173 Py_INCREF(offset);
1174 self->offset = offset;
1183 new_timezone(PyObject *offset, PyObject *name)
1185 assert(offset != NULL);
1186 assert(PyDelta_Check(offset));
1189 if (name == NULL && delta_bool((PyDateTime_Delta *)offset) == 0) {
1193 if ((GET_TD_DAYS(offset) == -1 &&
1194 GET_TD_SECONDS(offset) == 0 &&
1195 GET_TD_MICROSECONDS(offset) < 1) ||
1196 GET_TD_DAYS(offset) < -1 || GET_TD_DAYS(offset) >= 1) {
1197 PyErr_Format(PyExc_ValueError, "offset must be a timedelta"
1200 " not %R.", offset);
1204 return create_timezone(offset, name);
1253 PyObject *offset;
1261 offset = PyObject_CallMethod(tzinfo, name, "O", tzinfoarg);
1262 if (offset == Py_None || offset == NULL)
1263 return offset;
1264 if (PyDelta_Check(offset)) {
1265 if ((GET_TD_DAYS(offset) == -1 &&
1266 GET_TD_SECONDS(offset) == 0 &&
1267 GET_TD_MICROSECONDS(offset) < 1) ||
1268 GET_TD_DAYS(offset) < -1 || GET_TD_DAYS(offset) >= 1) {
1269 Py_DECREF(offset);
1270 PyErr_Format(PyExc_ValueError, "offset must be a timedelta"
1280 name, Py_TYPE(offset)->tp_name);
1281 Py_DECREF(offset);
1285 return offset;
1294 * set to 0 and the offset is returned (as timedelta, positive east of UTC).
1306 * returns -1. If dst() returns an invalid timedelta for a UTC offset,
1308 * the offset is returned (as timedelta, positive east of UTC).
1405 // Create a timezone from offset in seconds (0 returns UTC)
1451 /* Add formatted UTC offset string to buf. buf has no more than
1452 * buflen bytes remaining. The UTC offset is gotten by calling
1465 PyObject *offset;
1471 offset = call_utcoffset(tzinfo, tzinfoarg);
1472 if (offset == NULL)
1474 if (offset == Py_None) {
1475 Py_DECREF(offset);
1480 if (GET_TD_DAYS(offset) < 0) {
1482 Py_SETREF(offset, delta_negative((PyDateTime_Delta *)offset));
1483 if (offset == NULL)
1490 microseconds = GET_TD_MICROSECONDS(offset);
1491 seconds = GET_TD_SECONDS(offset);
1492 Py_DECREF(offset);
3847 PyDoc_STR("datetime -> timedelta showing offset from UTC, negative "
3851 PyDoc_STR("datetime -> DST offset as timedelta positive east of UTC.")},
3907 static char *timezone_kws[] = {"offset", "name", NULL};
3912 PyObject *offset;
3915 &PyDateTime_DeltaType, &offset, &name))
3916 return new_timezone(offset, name);
3924 Py_CLEAR(self->offset);
3938 return delta_richcompare(self->offset, other->offset, op);
3944 return delta_hash((PyDateTime_Delta *)self->offset);
3972 return PyUnicode_FromFormat("%s(%R)", type_name, self->offset);
3974 return PyUnicode_FromFormat("%s(%R, %R)", type_name, self->offset,
3983 PyObject *offset;
3991 (GET_TD_DAYS(self->offset) == 0 &&
3992 GET_TD_SECONDS(self->offset) == 0 &&
3993 GET_TD_MICROSECONDS(self->offset) == 0))
3996 if (GET_TD_DAYS(self->offset) < 0) {
3998 offset = delta_negative((PyDateTime_Delta *)self->offset);
3999 if (offset == NULL)
4004 offset = self->offset;
4005 Py_INCREF(offset);
4008 microseconds = GET_TD_MICROSECONDS(offset);
4009 seconds = GET_TD_SECONDS(offset);
4010 Py_DECREF(offset);
4040 Py_INCREF(self->offset);
4041 return self->offset;
4067 return add_datetime_timedelta(dt, (PyDateTime_Delta *)self->offset, 1);
4074 return Py_BuildValue("(O)", self->offset);
4075 return Py_BuildValue("(OO)", self->offset, self->name);
4081 " Otherwise returns offset as 'UTC(+|-)HH:MM'.")},
4084 PyDoc_STR("Return fixed offset.")},
4099 PyDoc_STR("Fixed offset from UTC implementation of tzinfo.");
4421 /* We need to append the UTC offset. */
4530 "can't compare offset-naive and "
4531 "offset-aware times");
4543 PyObject *offset, *self0;
4558 offset = time_utcoffset(self0, NULL);
4561 if (offset == NULL)
4565 if (offset == Py_None)
4578 Py_DECREF(offset);
4581 temp2 = delta_subtract(temp1, offset);
4584 Py_DECREF(offset);
4590 Py_DECREF(offset);
5641 "can't subtract offset-naive and "
5642 "offset-aware datetimes");
5802 /* We need to append the UTC offset. */
5975 "can't compare offset-naive and "
5976 "offset-aware datetimes");
5988 PyObject *offset, *self0;
6006 offset = datetime_utcoffset(self0, NULL);
6009 if (offset == NULL)
6013 if (offset == Py_None)
6031 Py_DECREF(offset);
6034 temp2 = delta_subtract(temp1, offset);
6037 Py_DECREF(offset);
6043 Py_DECREF(offset);
6202 PyObject *offset;
6233 offset = call_utcoffset(self_tzinfo, (PyObject *)self);
6235 if (offset == NULL)
6237 else if(offset == Py_None) {
6238 Py_DECREF(offset);
6241 else if (!PyDelta_Check(offset)) {
6242 Py_DECREF(offset);
6244 " expected timedelta or None", Py_TYPE(offset)->tp_name);
6247 /* result = self - offset */
6249 (PyDateTime_Delta *)offset, -1);
6250 Py_DECREF(offset);
6450 PyObject *offset;
6451 offset = call_utcoffset(tzinfo, (PyObject *)self);
6452 if (offset == NULL)
6454 if (offset == Py_None) {
6455 Py_DECREF(offset);
6461 (PyDateTime_Delta *)offset, -1);
6462 Py_DECREF(offset);
6931 x.s = x's standard offset, x.o - x.d
6982 very large, since all offset-returning methods return a duration of magnitude
7033 If [5] is not true now, diff = z.d != 0, and z.d is the offset we need to
7065 a dst() offset, and starting *from* a time already in DST (we know z.d != 0),
7107 a region decides to change its base offset from UTC.
7114 "almost all" time zones: so long as the standard offset is invariant, it