DateTimeFile

class grill.names.DateTimeFile(name: str = '', sep: str = ' ')

Time based file names respecting iso standard.

Config:

year

Between datetime.MINYEAR and datetime.MAXYEAR inclusive.

month

Between 1 and 12 inclusive.

day

Between 1 and the number of days in the given month of the given year.

hour

In range(24).

minute

In range(60).

second

In range(60).

microsecond

In range(1000000).

Composed Fields:

date

year month day

time

hour minute second microsecond

Note

When getting a new default name, current ISO time at the moment of execution is used.

Example:
>>> tf = DateTimeFile.get_default(suffix='txt')
>>> tf.day
'28'
>>> tf.date
'2019-10-28'
>>> tf.year = 1999
>>> tf
DateTimeFile("1999-10-28 22-29-31-926548.txt")
>>> tf.month = 14  # ISO format validation
Traceback (most recent call last):
    ...
ValueError: month must be in 1..12
>>> tf.datetime
datetime.datetime(1999, 10, 28, 22, 29, 31, 926548)
get_pattern_list() list[str]

Fields / properties names (sorted) to be used when building names.

Defaults to [date, time] + keys of this name’s config

property datetime: datetime

Return a datetime.datetime object using this name values.

>>> tf = DateTimeFile("1999-10-28 22-29-31-926548.txt")
>>> tf.datetime
datetime.datetime(1999, 10, 28, 22, 29, 31, 926548)
property name: str

This object’s solved name.

Raises:

ValueError – If an invalid string is provided when setting the attribute.