core.bones.date

Module Contents

Classes

DateBone

class core.bones.date.DateBone(*, creationMagic: bool = False, date: bool = True, localize: bool = False, time: bool = True, updateMagic: bool = False, **kwargs)

Bases: viur.core.bones.base.BaseBone

type = date
singleValueFromClient(value: str, skel: viur.core.skeleton.SkeletonInstance, name: str, origData)

Reads a value from the client. If this value is valid for this bone, store this value and return None. Otherwise our previous value is left unchanged and an error-message is returned.

Value is assumed to be in local time zone only if both self.date and self.time are set to True and self.localize is True.

Value is valid if, when converted into String, it complies following formats:

  • is digit (may include one ‘-’) and valid POSIX timestamp: converted from timestamp; assumes UTC timezone

  • is digit (may include one ‘-’) and NOT valid POSIX timestamp and not date and time: interpreted as seconds after epoch

  • ‘now’: current time

  • ‘nowX’, where X converted into String is added as seconds to current time

  • ‘%H:%M:%S’ if not date and time

  • ‘%M:%S’ if not date and time

  • ‘%S’ if not date and time

  • ‘%Y-%m-%d %H:%M:%S’ (ISO date format)

  • ‘%Y-%m-%d %H:%M’ (ISO date format)

  • ‘%Y-%m-%d’ (ISO date format)

  • ‘%m/%d/%Y %H:%M:%S’ (US date-format)

  • ‘%m/%d/%Y %H:%M’ (US date-format)

  • ‘%m/%d/%Y’ (US date-format)

  • ‘%d.%m.%Y %H:%M:%S’ (EU date-format)

  • ‘%d.%m.%Y %H:%M’ (EU date-format)

  • ‘%d.%m.%Y’ (EU date-format)

The resulting year must be >= 1900.

Parameters:
  • name – Our name in the skeleton

  • valueUser-supplied request-data, has to be of valid format

Returns:

tuple[datetime or None, [Errors] or None]

isInvalid(value)

Ensure that year is >= 1900 Otherwise strftime will break later on.

guessTimeZone()

Guess the timezone the user is supposed to be in. If it cant be guessed, a safe default (UTC) is used

singleValueSerialize(value, skel: SkeletonInstance, name: str, parentIndexed: bool)
singleValueUnserialize(value)
buildDBFilter(name: str, skel: viur.core.skeleton.SkeletonInstance, dbFilter: viur.core.db.Query, rawFilter: Dict, prefix: str | None = None) viur.core.db.Query
performMagic(valuesCache, name, isAdd)