src/pylib/Lib/n_time

Source   Edit  

time for Nim

the only difference with Python's is where some types in time is str, there is string in n_time's.

e.g. n_time.ctime() returns a string

py diff

Currently, tm_name is either "LOCAL" or "Etc/UTC", due to std/times only returning those two.

Warning: A few of the format directives for strftime/strptime are not supported, and using them causes AssertDefect. They are listed in nstrfptime.NotImplDirectives

Consts

DefaultTimeFormat = "%a %b %d %H:%M:%S %Y"
Source   Edit  

Procs

proc asctime(): string {....raises: [], tags: [TimeEffect], forbids: [].}
Source   Edit  
func asctime(t: struct_time): string {....raises: [], tags: [], forbids: [].}
Source   Edit  
func asctime(tup: struct_time_tuple): typeof(asctime do:
  bind struct_time
  struct_time(tm_year: 1900, tm_mon: 1, tm_mday: 1, tm_yday: 1, tm_isdst: -1)) {.
    ...raises: [], tags: [], forbids: [].}
Source   Edit  
func asctime(tup: struct_time_tuple10): typeof(asctime do:
  bind struct_time
  struct_time(tm_year: 1900, tm_mon: 1, tm_mday: 1, tm_yday: 1, tm_isdst: -1)) {.
    ...raises: [], tags: [], forbids: [].}
Source   Edit  
func asctime(tup: struct_time_tuple11): typeof(asctime do:
  bind struct_time
  struct_time(tm_year: 1900, tm_mon: 1, tm_mday: 1, tm_yday: 1, tm_isdst: -1)) {.
    ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc ctime(): string {....raises: [], tags: [TimeEffect], forbids: [].}
Source   Edit  
proc ctime(secs: float | int64): string
Source   Edit  
proc strftime(format: string): string {....raises: [ValueError],
                                        tags: [TimeEffect], forbids: [].}
Source   Edit  
proc strptime(s: string): struct_time {....raises: [ValueError, TimeParseError,
    TimeFormatParseError], tags: [TimeEffect], forbids: [].}
Warning: In current implementation, whitespace in format string means itself AS-IS, unlike C or Python, where any whitespace means a serial of any whitespaces. If really wanting the behavior of C's, consider using std/strscan.
Warning: Current strptime is just locale-unaware, when it comes to "the locale's format", like "%x", it always uses the format of "C" locale, no matter what the locale is. a.k.a. Changing locale via C's api in <locale.h> doesn't affect this function.
Source   Edit