1  """
     2      babel.dates
     3      ~~~~~~~~~~~
     4
     5      Locale dependent formatting and parsing of dates and times.
     6
     7      The default locale for the functions in this module is determined by the
     8      following environment variables, in that order:
     9
    10       * ``LC_TIME``,
    11       * ``LC_ALL``, and
    12       * ``LANG``
    13
    14      :copyright: (c) 2013-2023 by the Babel Team.
    15      :license: BSD, see LICENSE for more details.
    16  """
    17  from __future__ import annotations
    18  import re
    19  import warnings
    20  from functools import lru_cache
    21  from typing import TYPE_CHECKING, SupportsInt
    22  try:
    23      import pytz
    24  except ModuleNotFoundError:
    25      pytz = None
    26      import zoneinfo
    27  import datetime
    28  from collections.abc import Iterable
    29  from babel import localtime
    30  from babel.core import Locale, default_locale, get_global
    31  from babel.localedata import LocaleDataDict
    32  if TYPE_CHECKING:
    33      from typing_extensions import Literal, TypeAlias
    34      _Instant: TypeAlias = datetime.date | datetime.time | float | None
    35      _PredefinedTimeFormat: TypeAlias = Literal['full', 'long', 'medium', 'short']
    36      _Context: TypeAlias = Literal['format', 'stand-alone']
    37      _DtOrTzinfo: TypeAlias = datetime.datetime | datetime.tzinfo | str | int | datetime.time | None
    38  NO_INHERITANCE_MARKER = '∅∅∅'
    39  UTC = datetime.timezone.utc
    40  LOCALTZ = localtime.LOCALTZ
    41  LC_TIME = default_locale('LC_TIME')
    42
    43  def _get_dt_and_tzinfo(dt_or_tzinfo: _DtOrTzinfo) -> tuple[datetime.datetime | None, datetime.tzinfo]:
    44      """
    45      Parse a `dt_or_tzinfo` value into a datetime and a tzinfo.
    46
    47      See the docs for this function's callers for semantics.
    48
    49      :rtype: tuple[datetime, tzinfo]
    50      """
    51      pass
    52
    53  def _get_tz_name(dt_or_tzinfo: _DtOrTzinfo) -> str:
    54      """
    55      Get the timezone name out of a time, datetime, or tzinfo object.
    56
    57      :rtype: str
    58      """
    59      pass
    60
    61  def _get_datetime(instant: _Instant) -> datetime.datetime:
    62      """
    63      Get a datetime out of an "instant" (date, time, datetime, number).
    64
    65      .. warning:: The return values of this function may depend on the system clock.
    66
    67      If the instant is None, the current moment is used.
    68      If the instant is a time, it's augmented with today's date.
    69
    70      Dates are converted to naive datetimes with midnight as the time component.
    71
    72      >>> from datetime import date, datetime
    73      >>> _get_datetime(date(2015, 1, 1))
    74      datetime.datetime(2015, 1, 1, 0, 0)
    75
    76      UNIX timestamps are converted to datetimes.
    77
    78      >>> _get_datetime(1400000000)
    79      datetime.datetime(2014, 5, 13, 16, 53, 20)
    80
    81      Other values are passed through as-is.
    82
    83      >>> x = datetime(2015, 1, 1)
    84      >>> _get_datetime(x) is x
    85      True
    86
    87      :param instant: date, time, datetime, integer, float or None
    88      :type instant: date|time|datetime|int|float|None
    89      :return: a datetime
    90      :rtype: datetime
    91      """
    92      pass
    93
    94  def _ensure_datetime_tzinfo(dt: datetime.datetime, tzinfo: datetime.tzinfo | None=None) -> datetime.datetime:
    95      """
    96      Ensure the datetime passed has an attached tzinfo.
    97
    98      If the datetime is tz-naive to begin with, UTC is attached.
    99
   100      If a tzinfo is passed in, the datetime is normalized to that timezone.
   101
   102      >>> from datetime import datetime
   103      >>> _get_tz_name(_ensure_datetime_tzinfo(datetime(2015, 1, 1)))
   104      'UTC'
   105
   106      >>> tz = get_timezone("Europe/Stockholm")
   107      >>> _ensure_datetime_tzinfo(datetime(2015, 1, 1, 13, 15, tzinfo=UTC), tzinfo=tz).hour
   108      14
   109
   110      :param datetime: Datetime to augment.
   111      :param tzinfo: optional tzinfo
   112      :return: datetime with tzinfo
   113      :rtype: datetime
   114      """
   115      pass
   116
   117  def _get_time(time: datetime.time | datetime.datetime | None, tzinfo: datetime.tzinfo | None=None) -> datetime.time:
   118      """
   119      Get a timezoned time from a given instant.
   120
   121      .. warning:: The return values of this function may depend on the system clock.
   122
   123      :param time: time, datetime or None
   124      :rtype: time
   125      """
   126      pass
   127
   128  def get_timezone(zone: str | datetime.tzinfo | None=None) -> datetime.tzinfo:
   129      """Looks up a timezone by name and returns it.  The timezone object
   130      returned comes from ``pytz`` or ``zoneinfo``, whichever is available.
   131      It corresponds to the `tzinfo` interface and can be used with all of
   132      the functions of Babel that operate with dates.
   133
   134      If a timezone is not known a :exc:`LookupError` is raised.  If `zone`
   135      is ``None`` a local zone object is returned.
   136
   137      :param zone: the name of the timezone to look up.  If a timezone object
   138                   itself is passed in, it's returned unchanged.
   139      """
   140      pass
   141
   142  def get_period_names(width: Literal['abbreviated', 'narrow', 'wide']='wide', context: _Context='stand-alone', locale: Locale | str | None=LC_TIME) -> LocaleDataDict:
   143      """Return the names for day periods (AM/PM) used by the locale.
   144
   145      >>> get_period_names(locale='en_US')['am']
   146      u'AM'
   147
   148      :param width: the width to use, one of "abbreviated", "narrow", or "wide"
   149      :param context: the context, either "format" or "stand-alone"
   150      :param locale: the `Locale` object, or a locale string
   151      """
   152      pass
   153
   154  def get_day_names(width: Literal['abbreviated', 'narrow', 'short', 'wide']='wide', context: _Context='format', locale: Locale | str | None=LC_TIME) -> LocaleDataDict:
   155      """Return the day names used by the locale for the specified format.
   156
   157      >>> get_day_names('wide', locale='en_US')[1]
   158      u'Tuesday'
   159      >>> get_day_names('short', locale='en_US')[1]
   160      u'Tu'
   161      >>> get_day_names('abbreviated', locale='es')[1]
   162      u'mar'
   163      >>> get_day_names('narrow', context='stand-alone', locale='de_DE')[1]
   164      u'D'
   165
   166      :param width: the width to use, one of "wide", "abbreviated", "short" or "narrow"
   167      :param context: the context, either "format" or "stand-alone"
   168      :param locale: the `Locale` object, or a locale string
   169      """
   170      pass
   171
   172  def get_month_names(width: Literal['abbreviated', 'narrow', 'wide']='wide', context: _Context='format', locale: Locale | str | None=LC_TIME) -> LocaleDataDict:
   173      """Return the month names used by the locale for the specified format.
   174
   175      >>> get_month_names('wide', locale='en_US')[1]
   176      u'January'
   177      >>> get_month_names('abbreviated', locale='es')[1]
   178      u'ene'
   179      >>> get_month_names('narrow', context='stand-alone', locale='de_DE')[1]
   180      u'J'
   181
   182      :param width: the width to use, one of "wide", "abbreviated", or "narrow"
   183      :param context: the context, either "format" or "stand-alone"
   184      :param locale: the `Locale` object, or a locale string
   185      """
   186      pass
   187
   188  def get_quarter_names(width: Literal['abbreviated', 'narrow', 'wide']='wide', context: _Context='format', locale: Locale | str | None=LC_TIME) -> LocaleDataDict:
   189      """Return the quarter names used by the locale for the specified format.
   190
   191      >>> get_quarter_names('wide', locale='en_US')[1]
   192      u'1st quarter'
   193      >>> get_quarter_names('abbreviated', locale='de_DE')[1]
   194      u'Q1'
   195      >>> get_quarter_names('narrow', locale='de_DE')[1]
   196      u'1'
   197
   198      :param width: the width to use, one of "wide", "abbreviated", or "narrow"
   199      :param context: the context, either "format" or "stand-alone"
   200      :param locale: the `Locale` object, or a locale string
   201      """
   202      pass
   203
   204  def get_era_names(width: Literal['abbreviated', 'narrow', 'wide']='wide', locale: Locale | str | None=LC_TIME) -> LocaleDataDict:
   205      """Return the era names used by the locale for the specified format.
   206
   207      >>> get_era_names('wide', locale='en_US')[1]
   208      u'Anno Domini'
   209      >>> get_era_names('abbreviated', locale='de_DE')[1]
   210      u'n. Chr.'
   211
   212      :param width: the width to use, either "wide", "abbreviated", or "narrow"
   213      :param locale: the `Locale` object, or a locale string
   214      """
   215      pass
   216
   217  def get_date_format(format: _PredefinedTimeFormat='medium', locale: Locale | str | None=LC_TIME) -> DateTimePattern:
   218      """Return the date formatting patterns used by the locale for the specified
   219      format.
   220
   221      >>> get_date_format(locale='en_US')
   222      <DateTimePattern u'MMM d, y'>
   223      >>> get_date_format('full', locale='de_DE')
   224      <DateTimePattern u'EEEE, d. MMMM y'>
   225
   226      :param format: the format to use, one of "full", "long", "medium", or
   227                     "short"
   228      :param locale: the `Locale` object, or a locale string
   229      """
   230      pass
   231
   232  def get_datetime_format(format: _PredefinedTimeFormat='medium', locale: Locale | str | None=LC_TIME) -> DateTimePattern:
   233      """Return the datetime formatting patterns used by the locale for the
   234      specified format.
   235
   236      >>> get_datetime_format(locale='en_US')
   237      u'{1}, {0}'
   238
   239      :param format: the format to use, one of "full", "long", "medium", or
   240                     "short"
   241      :param locale: the `Locale` object, or a locale string
   242      """
   243      pass
   244
   245  def get_time_format(format: _PredefinedTimeFormat='medium', locale: Locale | str | None=LC_TIME) -> DateTimePattern:
   246      """Return the time formatting patterns used by the locale for the specified
   247      format.
   248
   249      >>> get_time_format(locale='en_US')
   250      <DateTimePattern u'h:mm:ss\u202fa'>
   251      >>> get_time_format('full', locale='de_DE')
   252      <DateTimePattern u'HH:mm:ss zzzz'>
   253
   254      :param format: the format to use, one of "full", "long", "medium", or
   255                     "short"
   256      :param locale: the `Locale` object, or a locale string
   257      """
   258      pass
   259
   260  def get_timezone_gmt(datetime: _Instant=None, width: Literal['long', 'short', 'iso8601', 'iso8601_short']='long', locale: Locale | str | None=LC_TIME, return_z: bool=False) -> str:
   261      """Return the timezone associated with the given `datetime` object formatted
   262      as string indicating the offset from GMT.
   263
   264      >>> from datetime import datetime
   265      >>> dt = datetime(2007, 4, 1, 15, 30)
   266      >>> get_timezone_gmt(dt, locale='en')
   267      u'GMT+00:00'
   268      >>> get_timezone_gmt(dt, locale='en', return_z=True)
   269      'Z'
   270      >>> get_timezone_gmt(dt, locale='en', width='iso8601_short')
   271      u'+00'
   272      >>> tz = get_timezone('America/Los_Angeles')
   273      >>> dt = _localize(tz, datetime(2007, 4, 1, 15, 30))
   274      >>> get_timezone_gmt(dt, locale='en')
   275      u'GMT-07:00'
   276      >>> get_timezone_gmt(dt, 'short', locale='en')
   277      u'-0700'
   278      >>> get_timezone_gmt(dt, locale='en', width='iso8601_short')
   279      u'-07'
   280
   281      The long format depends on the locale, for example in France the acronym
   282      UTC string is used instead of GMT:
   283
   284      >>> get_timezone_gmt(dt, 'long', locale='fr_FR')
   285      u'UTC-07:00'
   286
   287      .. versionadded:: 0.9
   288
   289      :param datetime: the ``datetime`` object; if `None`, the current date and
   290                       time in UTC is used
   291      :param width: either "long" or "short" or "iso8601" or "iso8601_short"
   292      :param locale: the `Locale` object, or a locale string
   293      :param return_z: True or False; Function returns indicator "Z"
   294                       when local time offset is 0
   295      """
   296      pass
   297
   298  def get_timezone_location(dt_or_tzinfo: _DtOrTzinfo=None, locale: Locale | str | None=LC_TIME, return_city: bool=False) -> str:
   299      """Return a representation of the given timezone using "location format".
   300
   301      The result depends on both the local display name of the country and the
   302      city associated with the time zone:
   303
   304      >>> tz = get_timezone('America/St_Johns')
   305      >>> print(get_timezone_location(tz, locale='de_DE'))
   306      Kanada (St. John’s) (Ortszeit)
   307      >>> print(get_timezone_location(tz, locale='en'))
   308      Canada (St. John’s) Time
   309      >>> print(get_timezone_location(tz, locale='en', return_city=True))
   310      St. John’s
   311      >>> tz = get_timezone('America/Mexico_City')
   312      >>> get_timezone_location(tz, locale='de_DE')
   313      u'Mexiko (Mexiko-Stadt) (Ortszeit)'
   314
   315      If the timezone is associated with a country that uses only a single
   316      timezone, just the localized country name is returned:
   317
   318      >>> tz = get_timezone('Europe/Berlin')
   319      >>> get_timezone_name(tz, locale='de_DE')
   320      u'Mitteleurop\\xe4ische Zeit'
   321
   322      .. versionadded:: 0.9
   323
   324      :param dt_or_tzinfo: the ``datetime`` or ``tzinfo`` object that determines
   325                           the timezone; if `None`, the current date and time in
   326                           UTC is assumed
   327      :param locale: the `Locale` object, or a locale string
   328      :param return_city: True or False, if True then return exemplar city (location)
   329                          for the time zone
   330      :return: the localized timezone name using location format
   331
   332      """
   333      pass
   334
   335  def get_timezone_name(dt_or_tzinfo: _DtOrTzinfo=None, width: Literal['long', 'short']='long', uncommon: bool=False, locale: Locale | str | None=LC_TIME, zone_variant: Literal['generic', 'daylight', 'standard'] | None=None, return_zone: bool=False) -> str:
   336      """Return the localized disp<response clipped><NOTE>Due to the max output limit, only part of the full response has been shown to you.</NOTE>fo: datetime.tzinfo | None=None, locale: Locale | str | None=LC_TIME) -> str:
   433      """Return a date formatted according to the given pattern.
   434
   435      >>> from datetime import datetime
   436      >>> dt = datetime(2007, 4, 1, 15, 30)
   437      >>> format_datetime(dt, locale='en_US')
   438      u'Apr 1, 2007, 3:30:00\\u202fPM'
   439
   440      For any pattern requiring the display of the timezone:
   441
   442      >>> format_datetime(dt, 'full', tzinfo=get_timezone('Europe/Paris'),
   443      ...                 locale='fr_FR')
   444      'dimanche 1 avril 2007, 17:30:00 heure d’été d’Europe centrale'
   445      >>> format_datetime(dt, "yyyy.MM.dd G 'at' HH:mm:ss zzz",
   446      ...                 tzinfo=get_timezone('US/Eastern'), locale='en')
   447      u'2007.04.01 AD at 11:30:00 EDT'
   448
   449      :param datetime: the `datetime` object; if `None`, the current date and
   450                       time is used
   451      :param format: one of "full", "long", "medium", or "short", or a custom
   452                     date/time pattern
   453      :param tzinfo: the timezone to apply to the time for display
   454      :param locale: a `Locale` object or a locale identifier
   455      """
   456      pass
   457
   458  def format_time(time: datetime.time | datetime.datetime | float | None=None, format: _PredefinedTimeFormat | str='medium', tzinfo: datetime.tzinfo | None=None, locale: Locale | str | None=LC_TIME) -> str:
   459      """Return a time formatted according to the given pattern.
   460
   461      >>> from datetime import datetime, time
   462      >>> t = time(15, 30)
   463      >>> format_time(t, locale='en_US')
   464      u'3:30:00\\u202fPM'
   465      >>> format_time(t, format='short', locale='de_DE')
   466      u'15:30'
   467
   468      If you don't want to use the locale default formats, you can specify a
   469      custom time pattern:
   470
   471      >>> format_time(t, "hh 'o''clock' a", locale='en')
   472      u"03 o'clock PM"
   473
   474      For any pattern requiring the display of the time-zone a
   475      timezone has to be specified explicitly:
   476
   477      >>> t = datetime(2007, 4, 1, 15, 30)
   478      >>> tzinfo = get_timezone('Europe/Paris')
   479      >>> t = _localize(tzinfo, t)
   480      >>> format_time(t, format='full', tzinfo=tzinfo, locale='fr_FR')
   481      '15:30:00 heure d’été d’Europe centrale'
   482      >>> format_time(t, "hh 'o''clock' a, zzzz", tzinfo=get_timezone('US/Eastern'),
   483      ...             locale='en')
   484      u"09 o'clock AM, Eastern Daylight Time"
   485
   486      As that example shows, when this function gets passed a
   487      ``datetime.datetime`` value, the actual time in the formatted string is
   488      adjusted to the timezone specified by the `tzinfo` parameter. If the
   489      ``datetime`` is "naive" (i.e. it has no associated timezone information),
   490      it is assumed to be in UTC.
   491
   492      These timezone calculations are **not** performed if the value is of type
   493      ``datetime.time``, as without date information there's no way to determine
   494      what a given time would translate to in a different timezone without
   495      information about whether daylight savings time is in effect or not. This
   496      means that time values are left as-is, and the value of the `tzinfo`
   497      parameter is only used to display the timezone name if needed:
   498
   499      >>> t = time(15, 30)
   500      >>> format_time(t, format='full', tzinfo=get_timezone('Europe/Paris'),
   501      ...             locale='fr_FR')  # doctest: +SKIP
   502      u'15:30:00 heure normale d\\u2019Europe centrale'
   503      >>> format_time(t, format='full', tzinfo=get_timezone('US/Eastern'),
   504      ...             locale='en_US')  # doctest: +SKIP
   505      u'3:30:00\\u202fPM Eastern Standard Time'
   506
   507      :param time: the ``time`` or ``datetime`` object; if `None`, the current
   508                   time in UTC is used
   509      :param format: one of "full", "long", "medium", or "short", or a custom
   510                     date/time pattern
   511      :param tzinfo: the time-zone to apply to the time for display
   512      :param locale: a `Locale` object or a locale identifier
   513      """
   514      pass
   515
   516  def format_skeleton(skeleton: str, datetime: _Instant=None, tzinfo: datetime.tzinfo | None=None, fuzzy: bool=True, locale: Locale | str | None=LC_TIME) -> str:
   517      """Return a time and/or date formatted according to the given pattern.
   518
   519      The skeletons are defined in the CLDR data and provide more flexibility
   520      than the simple short/long/medium formats, but are a bit harder to use.
   521      The are defined using the date/time symbols without order or punctuation
   522      and map to a suitable format for the given locale.
   523
   524      >>> from datetime import datetime
   525      >>> t = datetime(2007, 4, 1, 15, 30)
   526      >>> format_skeleton('MMMEd', t, locale='fr')
   527      u'dim. 1 avr.'
   528      >>> format_skeleton('MMMEd', t, locale='en')
   529      u'Sun, Apr 1'
   530      >>> format_skeleton('yMMd', t, locale='fi')  # yMMd is not in the Finnish locale; yMd gets used
   531      u'1.4.2007'
   532      >>> format_skeleton('yMMd', t, fuzzy=False, locale='fi')  # yMMd is not in the Finnish locale, an error is thrown
   533      Traceback (most recent call last):
   534          ...
   535      KeyError: yMMd
   536
   537      After the skeleton is resolved to a pattern `format_datetime` is called so
   538      all timezone processing etc is the same as for that.
   539
   540      :param skeleton: A date time skeleton as defined in the cldr data.
   541      :param datetime: the ``time`` or ``datetime`` object; if `None`, the current
   542                   time in UTC is used
   543      :param tzinfo: the time-zone to apply to the time for display
   544      :param fuzzy: If the skeleton is not found, allow choosing a skeleton that's
   545                    close enough to it.
   546      :param locale: a `Locale` object or a locale identifier
   547      """
   548      pass
   549  TIMEDELTA_UNITS: tuple[tuple[str, int], ...] = (('year', 3600 * 24 * 365), ('month', 3600 * 24 * 30), ('week', 3600 * 24 * 7), ('day', 3600 * 24), ('hour', 3600), ('minute', 60), ('second', 1))
   550
   551  def format_timedelta(delta: datetime.timedelta | int, granularity: Literal['year', 'month', 'week', 'day', 'hour', 'minute', 'second']='second', threshold: float=0.85, add_direction: bool=False, format: Literal['narrow', 'short', 'medium', 'long']='long', locale: Locale | str | None=LC_TIME) -> str:
   552      """Return a time delta according to the rules of the given locale.
   553
   554      >>> from datetime import timedelta
   555      >>> format_timedelta(timedelta(weeks=12), locale='en_US')
   556      u'3 months'
   557      >>> format_timedelta(timedelta(seconds=1), locale='es')
   558      u'1 segundo'
   559
   560      The granularity parameter can be provided to alter the lowest unit
   561      presented, which defaults to a second.
   562
   563      >>> format_timedelta(timedelta(hours=3), granularity='day', locale='en_US')
   564      u'1 day'
   565
   566      The threshold parameter can be used to determine at which value the
   567      presentation switches to the next higher unit. A higher threshold factor
   568      means the presentation will switch later. For example:
   569
   570      >>> format_timedelta(timedelta(hours=23), threshold=0.9, locale='en_US')
   571      u'1 day'
   572      >>> format_timedelta(timedelta(hours=23), threshold=1.1, locale='en_US')
   573      u'23 hours'
   574
   575      In addition directional information can be provided that informs
   576      the user if the date is in the past or in the future:
   577
   578      >>> format_timedelta(timedelta(hours=1), add_direction=True, locale='en')
   579      u'in 1 hour'
   580      >>> format_timedelta(timedelta(hours=-1), add_direction=True, locale='en')
   581      u'1 hour ago'
   582
   583      The format parameter controls how compact or wide the presentation is:
   584
   585      >>> format_timedelta(timedelta(hours=3), format='short', locale='en')
   586      u'3 hr'
   587      >>> format_timedelta(timedelta(hours=3), format='narrow', locale='en')
   588      u'3h'
   589
   590      :param delta: a ``timedelta`` object representing the time difference to
   591                    format, or the delta in seconds as an `int` value
   592      :param granularity: determines the smallest unit that should be displayed,
   593                          the value can be one of "year", "month", "week", "day",
   594                          "hour", "minute" or "second"
   595      :param threshold: factor that determines at which point the presentation
   596                        switches to the next higher unit
   597      :param add_direction: if this flag is set to `True` the return value will
   598                            include directional information.  For instance a
   599                            positive timedelta will include the information about
   600                            it being in the future, a negative will be information
   601                            about the value being in the past.
   602      :param format: the format, can be "narrow", "short" or "long". (
   603                     "medium" is deprecated, currently converted to "long" to
   604                     maintain compatibility)
   605      :param locale: a `Locale` object or a locale identifier
   606      """
   607      pass
   608
   609  def format_interval(start: _Instant, end: _Instant, skeleton: str | None=None, tzinfo: datetime.tzinfo | None=None, fuzzy: bool=True, locale: Locale | str | None=LC_TIME) -> str:
   610      """
   611      Format an interval between two instants according to the locale's rules.
   612
   613      >>> from datetime import date, time
   614      >>> format_interval(date(2016, 1, 15), date(2016, 1, 17), "yMd", locale="fi")
   615      u'15.–17.1.2016'
   616
   617      >>> format_interval(time(12, 12), time(16, 16), "Hm", locale="en_GB")
   618      '12:12–16:16'
   619
   620      >>> format_interval(time(5, 12), time(16, 16), "hm", locale="en_US")
   621      '5:12\u202fAM\u2009–\u20094:16\u202fPM'
   622
   623      >>> format_interval(time(16, 18), time(16, 24), "Hm", locale="it")
   624      '16:18–16:24'
   625
   626      If the start instant equals the end instant, the interval is formatted like the instant.
   627
   628      >>> format_interval(time(16, 18), time(16, 18), "Hm", locale="it")
   629      '16:18'
   630
   631      Unknown skeletons fall back to "default" formatting.
   632
   633      >>> format_interval(date(2015, 1, 1), date(2017, 1, 1), "wzq", locale="ja")
   634      '2015/01/01～2017/01/01'
   635
   636      >>> format_interval(time(16, 18), time(16, 24), "xxx", locale="ja")
   637      '16:18:00～16:24:00'
   638
   639      >>> format_interval(date(2016, 1, 15), date(2016, 1, 17), "xxx", locale="de")
   640      '15.01.2016\u2009–\u200917.01.2016'
   641
   642      :param start: First instant (datetime/date/time)
   643      :param end: Second instant (datetime/date/time)
   644      :param skeleton: The "skeleton format" to use for formatting.
   645      :param tzinfo: tzinfo to use (if none is already attached)
   646      :param fuzzy: If the skeleton is not found, allow choosing a skeleton that's
   647                    close enough to it.
   648      :param locale: A locale object or identifier.
   649      :return: Formatted interval
   650      """
   651      pass
   652
   653  def get_period_id(time: _Instant, tzinfo: datetime.tzinfo | None=None, type: Literal['selection'] | None=None, locale: Locale | str | None=LC_TIME) -> str:
   654      """
   655      Get the day period ID for a given time.
   656
   657      This ID can be used as a key for the period name dictionary.
   658
   659      >>> from datetime import time
   660      >>> get_period_names(locale="de")[get_period_id(time(7, 42), locale="de")]
   661      u'Morgen'
   662
   663      >>> get_period_id(time(0), locale="en_US")
   664      u'midnight'
   665
   666      >>> get_period_id(time(0), type="selection", locale="en_US")
   667      u'night1'
   668
   669      :param time: The time to inspect.
   670      :param tzinfo: The timezone for the time. See ``format_time``.
   671      :param type: The period type to use. Either "selection" or None.
   672                   The selection type is used for selecting among phrases such as
   673                   “Your email arrived yesterday evening” or “Your email arrived last night”.
   674      :param locale: the `Locale` object, or a locale string
   675      :return: period ID. Something is always returned -- even if it's just "am" or "pm".
   676      """
   677      pass
   678
   679  class ParseError(ValueError):
   680      pass
   681
   682  def parse_date(string: str, locale: Locale | str | None=LC_TIME, format: _PredefinedTimeFormat='medium') -> datetime.date:
   683      """Parse a date from a string.
   684
   685      This function first tries to interpret the string as ISO-8601
   686      date format, then uses the date format for the locale as a hint to
   687      determine the order in which the date fields appear in the string.
   688
   689      >>> parse_date('4/1/04', locale='en_US')
   690      datetime.date(2004, 4, 1)
   691      >>> parse_date('01.04.2004', locale='de_DE')
   692      datetime.date(2004, 4, 1)
   693      >>> parse_date('2004-04-01', locale='en_US')
   694      datetime.date(2004, 4, 1)
   695      >>> parse_date('2004-04-01', locale='de_DE')
   696      datetime.date(2004, 4, 1)
   697
   698      :param string: the string containing the date
   699      :param locale: a `Locale` object or a locale identifier
   700      :param format: the format to use (see ``get_date_format``)
   701      """
   702      pass
   703
   704  def parse_time(string: str, locale: Locale | str | None=LC_TIME, format: _PredefinedTimeFormat='medium') -> datetime.time:
   705      """Parse a time from a string.
   706
   707      This function uses the time format for the locale as a hint to determine
   708      the order in which the time fields appear in the string.
   709
   710      >>> parse_time('15:30:00', locale='en_US')
   711      datetime.time(15, 30)
   712
   713      :param string: the string containing the time
   714      :param locale: a `Locale` object or a locale identifier
   715      :param format: the format to use (see ``get_time_format``)
   716      :return: the parsed time
   717      :rtype: `time`
   718      """
   719      pass
   720
[The command completed with exit code 0.]
[Current working directory: /workspace/babel]
[Python interpreter: /usr/bin/python]
[Command finished with exit code 0]