Qucs-S S-parameter Viewer & RF Synthesis Tools
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
babel.dates.DateTimeFormat Class Reference

Public Member Functions

None __init__ (self, datetime.date|datetime.time value, Locale|str locale, datetime.date|None reference_date=None)
 
str __getitem__ (self, str name)
 
int extract (self, str char)
 
str format_era (self, str char, int num)
 
str format_year (self, str char, int num)
 
str format_quarter (self, str char, int num)
 
str format_month (self, str char, int num)
 
str format_week (self, str char, int num)
 
str format_weekday (self, str char='E', int num=4)
 
str format_day_of_year (self, int num)
 
str format_day_of_week_in_month (self)
 
str format_period (self, str char, int num)
 
str format_frac_seconds (self, int num)
 
 format_milliseconds_in_day (self, num)
 
str format_timezone (self, str char, int num)
 
str format (self, SupportsInt value, int length)
 
int get_day_of_year (self, datetime.date|None date=None)
 
int get_week_of_year (self)
 
int get_week_of_month (self)
 
int get_week_number (self, int day_of_period, int|None day_of_week=None)
 

Public Attributes

 value
 
 locale
 
 reference_date
 

Static Public Attributes

dict PATTERN_CHARS
 

Member Function Documentation

◆ format_frac_seconds()

str babel.dates.DateTimeFormat.format_frac_seconds (   self,
int  num 
)
 Return fractional seconds.

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

◆ format_period()

str babel.dates.DateTimeFormat.format_period (   self,
str  char,
int  num 
)
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'清晨'

:param char: pattern format character ('a', 'b', 'B')
:param num: count of format character

◆ format_weekday()

str babel.dates.DateTimeFormat.format_weekday (   self,
str   char = 'E',
int   num = 4 
)
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

◆ get_week_number()

int babel.dates.DateTimeFormat.get_week_number (   self,
int  day_of_period,
int | None   day_of_week = None 
)
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

◆ get_week_of_month()

int babel.dates.DateTimeFormat.get_week_of_month (   self)
Return the week of the month.

◆ get_week_of_year()

int babel.dates.DateTimeFormat.get_week_of_year (   self)
Return the week of the year.

Member Data Documentation

◆ PATTERN_CHARS

dict babel.dates.DateTimeFormat.PATTERN_CHARS
static
Initial value:
= {
'G': [1, 2, 3, 4, 5], # era
'y': None, 'Y': None, 'u': None, # year
'Q': [1, 2, 3, 4, 5], 'q': [1, 2, 3, 4, 5], # quarter
'M': [1, 2, 3, 4, 5], 'L': [1, 2, 3, 4, 5], # month
'w': [1, 2], 'W': [1], # week
'd': [1, 2], 'D': [1, 2, 3], 'F': [1], 'g': None, # day
'E': [1, 2, 3, 4, 5, 6], 'e': [1, 2, 3, 4, 5, 6], 'c': [1, 3, 4, 5, 6], # week day
'a': [1, 2, 3, 4, 5], 'b': [1, 2, 3, 4, 5], 'B': [1, 2, 3, 4, 5], # period
'h': [1, 2], 'H': [1, 2], 'K': [1, 2], 'k': [1, 2], # hour
'm': [1, 2], # minute
's': [1, 2], 'S': None, 'A': None, # second
'z': [1, 2, 3, 4], 'Z': [1, 2, 3, 4, 5], 'O': [1, 4], 'v': [1, 4], # zone
'V': [1, 2, 3, 4], 'x': [1, 2, 3, 4, 5], 'X': [1, 2, 3, 4, 5], # zone
}

The documentation for this class was generated from the following file: