src/pylib/Lib/time_impl/nstrfptime

Search:
Group by:
Source   Edit  

strftime, strptime

platform independent implementation.

Consts

docTable = (module: "", api: (data: [], counter: 0))
used to transport doc string to outer module. Source   Edit  
NotImplDirectives = {'y', 'Z'}

Here are their concrete meanings in Python, as well as some notes about why they cannot be directly mapped to Nim's DateTime.format/parse.

The direct alternative value when formatting in Nim, if any, is introduced by <-:

  • y: Year without century as a decimal number [00,99]. <- DateTime.format"yy" When parsing, C/Python's %y use 20th or 21th centry depending on the value of %y Nim's yy use the current century
  • Z: Time zone name (no characters if no time zone exists). Deprecated. However, this is supported in Lib/datetime

Following are strftime only currently:

  • j: Day of the year as a decimal number [001,366]. <- DateTime.yearday + 1
  • u: Weekday [0(Monday), 6]. <- DateTime.weekday.int
  • w: Weekday [0(Sunday),6]. <- (DateTime.weekday.int + 1) mod 7
  • U: Week number of the year (Sunday as the first day of the week) as a decimal number [00,53]. All days in a new year preceding the first Sunday are considered to be in week 0.
Source   Edit  

Procs

func strftime(format: string; dt: DateTime): string {....raises: [], tags: [],
    forbids: [].}
Source   Edit  
proc strptime(dt: var DateTime; s: string; format_with_sp_asis: string) {.
    ...raises: [ValueError, TimeParseError, TimeFormatParseError],
    tags: [TimeEffect], forbids: [].}
Source   Edit