class documentation

class DateTimeFormat: (source)

View In Hierarchy

Undocumented

Method __getitem__ Undocumented
Method __init__ Undocumented
Method extract Undocumented
Method format Undocumented
Method format_day_of_week_in_month Undocumented
Method format_day_of_year Undocumented
Method format_era Undocumented
Method format_frac_seconds Return fractional seconds.
Method format_milliseconds_in_day Undocumented
Method format_month Undocumented
Method format_period Return period from parsed datetime according to format pattern.
Method format_quarter Undocumented
Method format_timezone Undocumented
Method format_week Undocumented
Method format_weekday Return weekday from parsed datetime according to format pattern.
Method format_year Undocumented
Method get_day_of_year Undocumented
Method get_week_number Return the number of the week of a day within a period. This may be the week number in a year or the week number in a month.
Instance Variable locale Undocumented
Instance Variable reference_date Undocumented
Instance Variable value Undocumented
def __getitem__(self, name: str) -> str: (source)

Undocumented

def __init__(self, value: datetime.date|datetime.time, locale: Locale|str, reference_date: datetime.date|None = None): (source)

Undocumented

def extract(self, char: str) -> int: (source)

Undocumented

def format(self, value: SupportsInt, length: int) -> str: (source)

Undocumented

def format_day_of_week_in_month(self) -> str: (source)

Undocumented

def format_day_of_year(self, num: int) -> str: (source)

Undocumented

def format_era(self, char: str, num: int) -> str: (source)

Undocumented

def format_frac_seconds(self, num: int) -> str: (source)

Return fractional seconds. Rounds the time's microseconds to the precision given by the number of digits passed in.

def format_milliseconds_in_day(self, num): (source)

Undocumented

def format_month(self, char: str, num: int) -> str: (source)

Undocumented

def format_period(self, char: str, num: int) -> str: (source)

Return period from parsed datetime according to format pattern. >>> from datetime import datetime, time >>> format = DateTimeFormat(time(13, 42), 'fi_FI') >>> format.format_period('a', 1) u'ip.' >>> format.format_period('b', 1) u'iltap.' >>> format.format_period('b', 4) u'iltapäivä' >>> format.format_period('B', 4) u'iltapäivällä' >>> format.format_period('B', 5) u'ip.' >>> format = DateTimeFormat(datetime(2022, 4, 28, 6, 27), 'zh_Hant') >>> format.format_period('a', 1) u'上午' >>> format.format_period('b', 1) u'清晨' >>> format.format_period('B', 1) u'清晨' :param char: pattern format character ('a', 'b', 'B') :param num: count of format character

def format_quarter(self, char: str, num: int) -> str: (source)

Undocumented

def format_timezone(self, char: str, num: int) -> str: (source)

Undocumented

def format_week(self, char: str, num: int) -> str: (source)

Undocumented

def format_weekday(self, char: str = 'E', num: int = 4) -> str: (source)

Return weekday from parsed datetime according to format pattern. >>> from datetime import date >>> format = DateTimeFormat(date(2016, 2, 28), Locale.parse('en_US')) >>> format.format_weekday() u'Sunday' 'E': Day of week - Use one through three letters for the abbreviated day name, four for the full (wide) name, five for the narrow name, or six for the short name. >>> format.format_weekday('E',2) u'Sun' 'e': Local day of week. Same as E except adds a numeric value that will depend on the local starting day of the week, using one or two letters. For this example, Monday is the first day of the week. >>> format.format_weekday('e',2) '01' 'c': Stand-Alone local day of week - Use one letter for the local numeric value (same as 'e'), three for the abbreviated day name, four for the full (wide) name, five for the narrow name, or six for the short name. >>> format.format_weekday('c',1) '1' :param char: pattern format character ('e','E','c') :param num: count of format character

def format_year(self, char: str, num: int) -> str: (source)

Undocumented

def get_day_of_year(self, date: datetime.date|None = None) -> int: (source)

Undocumented

def get_week_number(self, day_of_period: int, day_of_week: int|None = None) -> int: (source)

Return the number of the week of a day within a period. This may be the week number in a year or the week number in a month. Usually this will return a value equal to or greater than 1, but if the first week of the period is so short that it actually counts as the last week of the previous period, this function will return 0. >>> date = datetime.date(2006, 1, 8) >>> DateTimeFormat(date, 'de_DE').get_week_number(6) 1 >>> DateTimeFormat(date, 'en_US').get_week_number(6) 2 :param day_of_period: the number of the day in the period (usually either the day of month or the day of year) :param day_of_week: the week day; if omitted, the week day of the current date is assumed

Undocumented

reference_date = (source)

Undocumented

Undocumented