Merge pull request #2732 from Perelandric/fix_miliseconds
Fixed 'milliseconds' spelling in code and docs
This commit is contained in:
commit
63f1e03278
9 changed files with 42 additions and 33 deletions
|
|
@ -1154,7 +1154,7 @@ else:
|
||||||
|
|
||||||
proc sleepAsync*(ms: int): Future[void] =
|
proc sleepAsync*(ms: int): Future[void] =
|
||||||
## Suspends the execution of the current async procedure for the next
|
## Suspends the execution of the current async procedure for the next
|
||||||
## ``ms`` miliseconds.
|
## ``ms`` milliseconds.
|
||||||
var retFuture = newFuture[void]("sleepAsync")
|
var retFuture = newFuture[void]("sleepAsync")
|
||||||
let p = getGlobalDispatcher()
|
let p = getGlobalDispatcher()
|
||||||
p.timers.add((epochTime() + (ms / 1000), retFuture))
|
p.timers.add((epochTime() + (ms / 1000), retFuture))
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@
|
||||||
## ========
|
## ========
|
||||||
## Currently all functions support an optional timeout, by default the timeout is set to
|
## Currently all functions support an optional timeout, by default the timeout is set to
|
||||||
## `-1` which means that the function will never time out. The timeout is
|
## `-1` which means that the function will never time out. The timeout is
|
||||||
## measured in miliseconds, once it is set any call on a socket which may
|
## measured in milliseconds, once it is set any call on a socket which may
|
||||||
## block will be susceptible to this timeout, however please remember that the
|
## block will be susceptible to this timeout, however please remember that the
|
||||||
## function as a whole can take longer than the specified timeout, only
|
## function as a whole can take longer than the specified timeout, only
|
||||||
## individual internal calls on the socket are affected. In practice this means
|
## individual internal calls on the socket are affected. In practice this means
|
||||||
|
|
@ -386,7 +386,7 @@ proc request*(url: string, httpMethod: string, extraHeaders = "",
|
||||||
## | Requests ``url`` with the custom method string specified by the
|
## | Requests ``url`` with the custom method string specified by the
|
||||||
## | ``httpMethod`` parameter.
|
## | ``httpMethod`` parameter.
|
||||||
## | Extra headers can be specified and must be separated by ``\c\L``
|
## | Extra headers can be specified and must be separated by ``\c\L``
|
||||||
## | An optional timeout can be specified in miliseconds, if reading from the
|
## | An optional timeout can be specified in milliseconds, if reading from the
|
||||||
## server takes longer than specified an ETimeout exception will be raised.
|
## server takes longer than specified an ETimeout exception will be raised.
|
||||||
var r = if proxy == nil: parseUri(url) else: proxy.url
|
var r = if proxy == nil: parseUri(url) else: proxy.url
|
||||||
var headers = substr(httpMethod, len("http"))
|
var headers = substr(httpMethod, len("http"))
|
||||||
|
|
@ -440,7 +440,7 @@ proc request*(url: string, httpMethod = httpGET, extraHeaders = "",
|
||||||
userAgent = defUserAgent, proxy: Proxy = nil): Response =
|
userAgent = defUserAgent, proxy: Proxy = nil): Response =
|
||||||
## | Requests ``url`` with the specified ``httpMethod``.
|
## | Requests ``url`` with the specified ``httpMethod``.
|
||||||
## | Extra headers can be specified and must be separated by ``\c\L``
|
## | Extra headers can be specified and must be separated by ``\c\L``
|
||||||
## | An optional timeout can be specified in miliseconds, if reading from the
|
## | An optional timeout can be specified in milliseconds, if reading from the
|
||||||
## server takes longer than specified an ETimeout exception will be raised.
|
## server takes longer than specified an ETimeout exception will be raised.
|
||||||
result = request(url, $httpMethod, extraHeaders, body, sslContext, timeout,
|
result = request(url, $httpMethod, extraHeaders, body, sslContext, timeout,
|
||||||
userAgent, proxy)
|
userAgent, proxy)
|
||||||
|
|
@ -467,7 +467,7 @@ proc get*(url: string, extraHeaders = "", maxRedirects = 5,
|
||||||
## | GETs the ``url`` and returns a ``Response`` object
|
## | GETs the ``url`` and returns a ``Response`` object
|
||||||
## | This proc also handles redirection
|
## | This proc also handles redirection
|
||||||
## | Extra headers can be specified and must be separated by ``\c\L``.
|
## | Extra headers can be specified and must be separated by ``\c\L``.
|
||||||
## | An optional timeout can be specified in miliseconds, if reading from the
|
## | An optional timeout can be specified in milliseconds, if reading from the
|
||||||
## server takes longer than specified an ETimeout exception will be raised.
|
## server takes longer than specified an ETimeout exception will be raised.
|
||||||
result = request(url, httpGET, extraHeaders, "", sslContext, timeout,
|
result = request(url, httpGET, extraHeaders, "", sslContext, timeout,
|
||||||
userAgent, proxy)
|
userAgent, proxy)
|
||||||
|
|
@ -486,7 +486,7 @@ proc getContent*(url: string, extraHeaders = "", maxRedirects = 5,
|
||||||
## | GETs the body and returns it as a string.
|
## | GETs the body and returns it as a string.
|
||||||
## | Raises exceptions for the status codes ``4xx`` and ``5xx``
|
## | Raises exceptions for the status codes ``4xx`` and ``5xx``
|
||||||
## | Extra headers can be specified and must be separated by ``\c\L``.
|
## | Extra headers can be specified and must be separated by ``\c\L``.
|
||||||
## | An optional timeout can be specified in miliseconds, if reading from the
|
## | An optional timeout can be specified in milliseconds, if reading from the
|
||||||
## server takes longer than specified an ETimeout exception will be raised.
|
## server takes longer than specified an ETimeout exception will be raised.
|
||||||
var r = get(url, extraHeaders, maxRedirects, sslContext, timeout, userAgent,
|
var r = get(url, extraHeaders, maxRedirects, sslContext, timeout, userAgent,
|
||||||
proxy)
|
proxy)
|
||||||
|
|
@ -505,7 +505,7 @@ proc post*(url: string, extraHeaders = "", body = "",
|
||||||
## | This proc adds the necessary Content-Length header.
|
## | This proc adds the necessary Content-Length header.
|
||||||
## | This proc also handles redirection.
|
## | This proc also handles redirection.
|
||||||
## | Extra headers can be specified and must be separated by ``\c\L``.
|
## | Extra headers can be specified and must be separated by ``\c\L``.
|
||||||
## | An optional timeout can be specified in miliseconds, if reading from the
|
## | An optional timeout can be specified in milliseconds, if reading from the
|
||||||
## server takes longer than specified an ETimeout exception will be raised.
|
## server takes longer than specified an ETimeout exception will be raised.
|
||||||
## | The optional ``multipart`` parameter can be used to create
|
## | The optional ``multipart`` parameter can be used to create
|
||||||
## ``multipart/form-data`` POSTs comfortably.
|
## ``multipart/form-data`` POSTs comfortably.
|
||||||
|
|
@ -542,7 +542,7 @@ proc postContent*(url: string, extraHeaders = "", body = "",
|
||||||
## | POSTs ``body`` to ``url`` and returns the response's body as a string
|
## | POSTs ``body`` to ``url`` and returns the response's body as a string
|
||||||
## | Raises exceptions for the status codes ``4xx`` and ``5xx``
|
## | Raises exceptions for the status codes ``4xx`` and ``5xx``
|
||||||
## | Extra headers can be specified and must be separated by ``\c\L``.
|
## | Extra headers can be specified and must be separated by ``\c\L``.
|
||||||
## | An optional timeout can be specified in miliseconds, if reading from the
|
## | An optional timeout can be specified in milliseconds, if reading from the
|
||||||
## server takes longer than specified an ETimeout exception will be raised.
|
## server takes longer than specified an ETimeout exception will be raised.
|
||||||
## | The optional ``multipart`` parameter can be used to create
|
## | The optional ``multipart`` parameter can be used to create
|
||||||
## ``multipart/form-data`` POSTs comfortably.
|
## ``multipart/form-data`` POSTs comfortably.
|
||||||
|
|
@ -558,7 +558,7 @@ proc downloadFile*(url: string, outputFilename: string,
|
||||||
timeout = -1, userAgent = defUserAgent,
|
timeout = -1, userAgent = defUserAgent,
|
||||||
proxy: Proxy = nil) =
|
proxy: Proxy = nil) =
|
||||||
## | Downloads ``url`` and saves it to ``outputFilename``
|
## | Downloads ``url`` and saves it to ``outputFilename``
|
||||||
## | An optional timeout can be specified in miliseconds, if reading from the
|
## | An optional timeout can be specified in milliseconds, if reading from the
|
||||||
## server takes longer than specified an ETimeout exception will be raised.
|
## server takes longer than specified an ETimeout exception will be raised.
|
||||||
var f: File
|
var f: File
|
||||||
if open(f, outputFilename, fmWrite):
|
if open(f, outputFilename, fmWrite):
|
||||||
|
|
|
||||||
|
|
@ -704,7 +704,7 @@ proc waitFor(socket: Socket, waited: var float, timeout, size: int,
|
||||||
|
|
||||||
proc recv*(socket: Socket, data: pointer, size: int, timeout: int): int {.
|
proc recv*(socket: Socket, data: pointer, size: int, timeout: int): int {.
|
||||||
tags: [ReadIOEffect, TimeEffect].} =
|
tags: [ReadIOEffect, TimeEffect].} =
|
||||||
## overload with a ``timeout`` parameter in miliseconds.
|
## overload with a ``timeout`` parameter in milliseconds.
|
||||||
var waited = 0.0 # number of seconds already waited
|
var waited = 0.0 # number of seconds already waited
|
||||||
|
|
||||||
var read = 0
|
var read = 0
|
||||||
|
|
@ -729,7 +729,7 @@ proc recv*(socket: Socket, data: var string, size: int, timeout = -1,
|
||||||
## This function will throw an EOS exception when an error occurs. A value
|
## This function will throw an EOS exception when an error occurs. A value
|
||||||
## lower than 0 is never returned.
|
## lower than 0 is never returned.
|
||||||
##
|
##
|
||||||
## A timeout may be specified in miliseconds, if enough data is not received
|
## A timeout may be specified in milliseconds, if enough data is not received
|
||||||
## within the time specified an ETimeout exception will be raised.
|
## within the time specified an ETimeout exception will be raised.
|
||||||
##
|
##
|
||||||
## **Note**: ``data`` must be initialised.
|
## **Note**: ``data`` must be initialised.
|
||||||
|
|
@ -777,7 +777,7 @@ proc readLine*(socket: Socket, line: var TaintedString, timeout = -1,
|
||||||
##
|
##
|
||||||
## An EOS exception will be raised in the case of a socket error.
|
## An EOS exception will be raised in the case of a socket error.
|
||||||
##
|
##
|
||||||
## A timeout can be specified in miliseconds, if data is not received within
|
## A timeout can be specified in milliseconds, if data is not received within
|
||||||
## the specified time an ETimeout exception will be raised.
|
## the specified time an ETimeout exception will be raised.
|
||||||
##
|
##
|
||||||
## **Warning**: Only the ``SafeDisconn`` flag is currently supported.
|
## **Warning**: Only the ``SafeDisconn`` flag is currently supported.
|
||||||
|
|
@ -844,7 +844,7 @@ proc recvFrom*(socket: Socket, data: var string, length: int,
|
||||||
proc skip*(socket: Socket, size: int, timeout = -1) =
|
proc skip*(socket: Socket, size: int, timeout = -1) =
|
||||||
## Skips ``size`` amount of bytes.
|
## Skips ``size`` amount of bytes.
|
||||||
##
|
##
|
||||||
## An optional timeout can be specified in miliseconds, if skipping the
|
## An optional timeout can be specified in milliseconds, if skipping the
|
||||||
## bytes takes longer than specified an ETimeout exception will be raised.
|
## bytes takes longer than specified an ETimeout exception will be raised.
|
||||||
##
|
##
|
||||||
## Returns the number of skipped bytes.
|
## Returns the number of skipped bytes.
|
||||||
|
|
@ -967,7 +967,7 @@ proc connect*(socket: Socket, address: string, port = Port(0), timeout: int,
|
||||||
af: Domain = AF_INET) {.tags: [ReadIOEffect, WriteIOEffect].} =
|
af: Domain = AF_INET) {.tags: [ReadIOEffect, WriteIOEffect].} =
|
||||||
## Connects to server as specified by ``address`` on port specified by ``port``.
|
## Connects to server as specified by ``address`` on port specified by ``port``.
|
||||||
##
|
##
|
||||||
## The ``timeout`` paremeter specifies the time in miliseconds to allow for
|
## The ``timeout`` paremeter specifies the time in milliseconds to allow for
|
||||||
## the connection to the server to be made.
|
## the connection to the server to be made.
|
||||||
socket.fd.setBlocking(false)
|
socket.fd.setBlocking(false)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -303,7 +303,7 @@ proc execProcesses*(cmds: openArray[string],
|
||||||
close(p)
|
close(p)
|
||||||
|
|
||||||
proc select*(readfds: var seq[Process], timeout = 500): int
|
proc select*(readfds: var seq[Process], timeout = 500): int
|
||||||
## `select` with a sensible Nim interface. `timeout` is in miliseconds.
|
## `select` with a sensible Nim interface. `timeout` is in milliseconds.
|
||||||
## Specify -1 for no timeout. Returns the number of processes that are
|
## Specify -1 for no timeout. Returns the number of processes that are
|
||||||
## ready to read from. The processes that are ready to be read from are
|
## ready to read from. The processes that are ready to be read from are
|
||||||
## removed from `readfds`.
|
## removed from `readfds`.
|
||||||
|
|
|
||||||
|
|
@ -392,7 +392,7 @@ proc select*(readfds: var seq[SocketHandle], timeout = 500): int =
|
||||||
## Traditional select function. This function will return the number of
|
## Traditional select function. This function will return the number of
|
||||||
## sockets that are ready to be read from, written to, or which have errors.
|
## sockets that are ready to be read from, written to, or which have errors.
|
||||||
## If there are none; 0 is returned.
|
## If there are none; 0 is returned.
|
||||||
## ``Timeout`` is in miliseconds and -1 can be specified for no timeout.
|
## ``Timeout`` is in milliseconds and -1 can be specified for no timeout.
|
||||||
##
|
##
|
||||||
## A socket is removed from the specific ``seq`` when it has data waiting to
|
## A socket is removed from the specific ``seq`` when it has data waiting to
|
||||||
## be read/written to or has errors (``exceptfds``).
|
## be read/written to or has errors (``exceptfds``).
|
||||||
|
|
@ -416,7 +416,7 @@ proc selectWrite*(writefds: var seq[SocketHandle],
|
||||||
## written to. The sockets which can be written to will also be removed
|
## written to. The sockets which can be written to will also be removed
|
||||||
## from ``writefds``.
|
## from ``writefds``.
|
||||||
##
|
##
|
||||||
## ``timeout`` is specified in miliseconds and ``-1`` can be specified for
|
## ``timeout`` is specified in milliseconds and ``-1`` can be specified for
|
||||||
## an unlimited time.
|
## an unlimited time.
|
||||||
var tv {.noInit.}: Timeval = timeValFromMilliseconds(timeout)
|
var tv {.noInit.}: Timeval = timeValFromMilliseconds(timeout)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -126,7 +126,7 @@ proc close*(s: var ScgiState) =
|
||||||
s.server.close()
|
s.server.close()
|
||||||
|
|
||||||
proc next*(s: var ScgiState, timeout: int = -1): bool =
|
proc next*(s: var ScgiState, timeout: int = -1): bool =
|
||||||
## proceed to the first/next request. Waits ``timeout`` miliseconds for a
|
## proceed to the first/next request. Waits ``timeout`` milliseconds for a
|
||||||
## request, if ``timeout`` is `-1` then this function will never time out.
|
## request, if ``timeout`` is `-1` then this function will never time out.
|
||||||
## Returns `true` if a new request has been processed.
|
## Returns `true` if a new request has been processed.
|
||||||
var rsocks = @[s.server]
|
var rsocks = @[s.server]
|
||||||
|
|
|
||||||
|
|
@ -986,7 +986,7 @@ proc select*(readfds, writefds, exceptfds: var seq[Socket],
|
||||||
## Traditional select function. This function will return the number of
|
## Traditional select function. This function will return the number of
|
||||||
## sockets that are ready to be read from, written to, or which have errors.
|
## sockets that are ready to be read from, written to, or which have errors.
|
||||||
## If there are none; 0 is returned.
|
## If there are none; 0 is returned.
|
||||||
## ``Timeout`` is in miliseconds and -1 can be specified for no timeout.
|
## ``Timeout`` is in milliseconds and -1 can be specified for no timeout.
|
||||||
##
|
##
|
||||||
## Sockets which are **not** ready for reading, writing or which don't have
|
## Sockets which are **not** ready for reading, writing or which don't have
|
||||||
## errors waiting on them are removed from the ``readfds``, ``writefds``,
|
## errors waiting on them are removed from the ``readfds``, ``writefds``,
|
||||||
|
|
@ -1040,7 +1040,7 @@ proc selectWrite*(writefds: var seq[Socket],
|
||||||
## written to. The sockets which **cannot** be written to will also be removed
|
## written to. The sockets which **cannot** be written to will also be removed
|
||||||
## from ``writefds``.
|
## from ``writefds``.
|
||||||
##
|
##
|
||||||
## ``timeout`` is specified in miliseconds and ``-1`` can be specified for
|
## ``timeout`` is specified in milliseconds and ``-1`` can be specified for
|
||||||
## an unlimited time.
|
## an unlimited time.
|
||||||
var tv {.noInit.}: Timeval = timeValFromMilliseconds(timeout)
|
var tv {.noInit.}: Timeval = timeValFromMilliseconds(timeout)
|
||||||
|
|
||||||
|
|
@ -1174,7 +1174,7 @@ proc waitFor(socket: Socket, waited: var float, timeout, size: int,
|
||||||
|
|
||||||
proc recv*(socket: Socket, data: pointer, size: int, timeout: int): int {.
|
proc recv*(socket: Socket, data: pointer, size: int, timeout: int): int {.
|
||||||
tags: [ReadIOEffect, TimeEffect].} =
|
tags: [ReadIOEffect, TimeEffect].} =
|
||||||
## overload with a ``timeout`` parameter in miliseconds.
|
## overload with a ``timeout`` parameter in milliseconds.
|
||||||
var waited = 0.0 # number of seconds already waited
|
var waited = 0.0 # number of seconds already waited
|
||||||
|
|
||||||
var read = 0
|
var read = 0
|
||||||
|
|
@ -1197,7 +1197,7 @@ proc recv*(socket: Socket, data: var string, size: int, timeout = -1): int =
|
||||||
## This function will throw an EOS exception when an error occurs. A value
|
## This function will throw an EOS exception when an error occurs. A value
|
||||||
## lower than 0 is never returned.
|
## lower than 0 is never returned.
|
||||||
##
|
##
|
||||||
## A timeout may be specified in miliseconds, if enough data is not received
|
## A timeout may be specified in milliseconds, if enough data is not received
|
||||||
## within the time specified an ETimeout exception will be raised.
|
## within the time specified an ETimeout exception will be raised.
|
||||||
##
|
##
|
||||||
## **Note**: ``data`` must be initialised.
|
## **Note**: ``data`` must be initialised.
|
||||||
|
|
@ -1258,7 +1258,7 @@ proc recvLine*(socket: Socket, line: var TaintedString, timeout = -1): bool {.
|
||||||
## If the socket is disconnected, ``line`` will be set to ``""`` and ``True``
|
## If the socket is disconnected, ``line`` will be set to ``""`` and ``True``
|
||||||
## will be returned.
|
## will be returned.
|
||||||
##
|
##
|
||||||
## A timeout can be specified in miliseconds, if data is not received within
|
## A timeout can be specified in milliseconds, if data is not received within
|
||||||
## the specified time an ETimeout exception will be raised.
|
## the specified time an ETimeout exception will be raised.
|
||||||
##
|
##
|
||||||
## **Deprecated since version 0.9.2**: This function has been deprecated in
|
## **Deprecated since version 0.9.2**: This function has been deprecated in
|
||||||
|
|
@ -1302,7 +1302,7 @@ proc readLine*(socket: Socket, line: var TaintedString, timeout = -1) {.
|
||||||
##
|
##
|
||||||
## An EOS exception will be raised in the case of a socket error.
|
## An EOS exception will be raised in the case of a socket error.
|
||||||
##
|
##
|
||||||
## A timeout can be specified in miliseconds, if data is not received within
|
## A timeout can be specified in milliseconds, if data is not received within
|
||||||
## the specified time an ETimeout exception will be raised.
|
## the specified time an ETimeout exception will be raised.
|
||||||
|
|
||||||
template addNLIfEmpty(): stmt =
|
template addNLIfEmpty(): stmt =
|
||||||
|
|
@ -1433,7 +1433,7 @@ proc recv*(socket: Socket): TaintedString {.tags: [ReadIOEffect], deprecated.} =
|
||||||
proc recvTimeout*(socket: Socket, timeout: int): TaintedString {.
|
proc recvTimeout*(socket: Socket, timeout: int): TaintedString {.
|
||||||
tags: [ReadIOEffect], deprecated.} =
|
tags: [ReadIOEffect], deprecated.} =
|
||||||
## overloaded variant to support a ``timeout`` parameter, the ``timeout``
|
## overloaded variant to support a ``timeout`` parameter, the ``timeout``
|
||||||
## parameter specifies the amount of miliseconds to wait for data on the
|
## parameter specifies the amount of milliseconds to wait for data on the
|
||||||
## socket.
|
## socket.
|
||||||
##
|
##
|
||||||
## **Deprecated since version 0.9.2**: This function is not safe for use.
|
## **Deprecated since version 0.9.2**: This function is not safe for use.
|
||||||
|
|
@ -1554,7 +1554,7 @@ proc skip*(socket: Socket) {.tags: [ReadIOEffect], deprecated.} =
|
||||||
proc skip*(socket: Socket, size: int, timeout = -1) =
|
proc skip*(socket: Socket, size: int, timeout = -1) =
|
||||||
## Skips ``size`` amount of bytes.
|
## Skips ``size`` amount of bytes.
|
||||||
##
|
##
|
||||||
## An optional timeout can be specified in miliseconds, if skipping the
|
## An optional timeout can be specified in milliseconds, if skipping the
|
||||||
## bytes takes longer than specified an ETimeout exception will be raised.
|
## bytes takes longer than specified an ETimeout exception will be raised.
|
||||||
##
|
##
|
||||||
## Returns the number of skipped bytes.
|
## Returns the number of skipped bytes.
|
||||||
|
|
@ -1708,7 +1708,7 @@ proc connect*(socket: Socket, address: string, port = Port(0), timeout: int,
|
||||||
af: Domain = AF_INET) {.tags: [ReadIOEffect, WriteIOEffect].} =
|
af: Domain = AF_INET) {.tags: [ReadIOEffect, WriteIOEffect].} =
|
||||||
## Connects to server as specified by ``address`` on port specified by ``port``.
|
## Connects to server as specified by ``address`` on port specified by ``port``.
|
||||||
##
|
##
|
||||||
## The ``timeout`` paremeter specifies the time in miliseconds to allow for
|
## The ``timeout`` paremeter specifies the time in milliseconds to allow for
|
||||||
## the connection to the server to be made.
|
## the connection to the server to be made.
|
||||||
let originalStatus = not socket.nonblocking
|
let originalStatus = not socket.nonblocking
|
||||||
socket.setBlocking(false)
|
socket.setBlocking(false)
|
||||||
|
|
|
||||||
|
|
@ -134,7 +134,7 @@ type
|
||||||
## everything should be positive or everything negative. Zero is
|
## everything should be positive or everything negative. Zero is
|
||||||
## fine too. Mixed signs will lead to unexpected results.
|
## fine too. Mixed signs will lead to unexpected results.
|
||||||
TimeInterval* = object ## a time interval
|
TimeInterval* = object ## a time interval
|
||||||
miliseconds*: int ## The number of miliseconds
|
milliseconds*: int ## The number of milliseconds
|
||||||
seconds*: int ## The number of seconds
|
seconds*: int ## The number of seconds
|
||||||
minutes*: int ## The number of minutes
|
minutes*: int ## The number of minutes
|
||||||
hours*: int ## The number of hours
|
hours*: int ## The number of hours
|
||||||
|
|
@ -145,6 +145,11 @@ type
|
||||||
{.deprecated: [TMonth: Month, TWeekDay: WeekDay, TTime: Time,
|
{.deprecated: [TMonth: Month, TWeekDay: WeekDay, TTime: Time,
|
||||||
TTimeInterval: TimeInterval, TTimeInfo: TimeInfo].}
|
TTimeInterval: TimeInterval, TTimeInfo: TimeInfo].}
|
||||||
|
|
||||||
|
proc miliseconds*(t: TimeInterval): int {.deprecated.} = t.milliseconds
|
||||||
|
|
||||||
|
proc `miliseconds=`*(t:var TimeInterval, milliseconds: int) {.deprecated.} =
|
||||||
|
t.milliseconds = milliseconds
|
||||||
|
|
||||||
proc getTime*(): Time {.tags: [TimeEffect], benign.}
|
proc getTime*(): Time {.tags: [TimeEffect], benign.}
|
||||||
## gets the current calendar time as a UNIX epoch value (number of seconds
|
## gets the current calendar time as a UNIX epoch value (number of seconds
|
||||||
## elapsed since 1970) with integer precission. Use epochTime for higher
|
## elapsed since 1970) with integer precission. Use epochTime for higher
|
||||||
|
|
@ -208,13 +213,13 @@ proc getTimezone*(): int {.tags: [TimeEffect], raises: [], benign.}
|
||||||
## returns the offset of the local (non-DST) timezone in seconds west of UTC.
|
## returns the offset of the local (non-DST) timezone in seconds west of UTC.
|
||||||
|
|
||||||
proc getStartMilsecs*(): int {.deprecated, tags: [TimeEffect], benign.}
|
proc getStartMilsecs*(): int {.deprecated, tags: [TimeEffect], benign.}
|
||||||
## get the miliseconds from the start of the program. **Deprecated since
|
## get the milliseconds from the start of the program. **Deprecated since
|
||||||
## version 0.8.10.** Use ``epochTime`` or ``cpuTime`` instead.
|
## version 0.8.10.** Use ``epochTime`` or ``cpuTime`` instead.
|
||||||
|
|
||||||
proc initInterval*(miliseconds, seconds, minutes, hours, days, months,
|
proc initInterval*(milliseconds, seconds, minutes, hours, days, months,
|
||||||
years: int = 0): TimeInterval =
|
years: int = 0): TimeInterval =
|
||||||
## creates a new ``TimeInterval``.
|
## creates a new ``TimeInterval``.
|
||||||
result.miliseconds = miliseconds
|
result.milliseconds = milliseconds
|
||||||
result.seconds = seconds
|
result.seconds = seconds
|
||||||
result.minutes = minutes
|
result.minutes = minutes
|
||||||
result.hours = hours
|
result.hours = hours
|
||||||
|
|
@ -264,7 +269,7 @@ proc toSeconds(a: TimeInfo, interval: TimeInterval): float =
|
||||||
result += float(newinterv.hours * 60 * 60)
|
result += float(newinterv.hours * 60 * 60)
|
||||||
result += float(newinterv.minutes * 60)
|
result += float(newinterv.minutes * 60)
|
||||||
result += float(newinterv.seconds)
|
result += float(newinterv.seconds)
|
||||||
result += newinterv.miliseconds / 1000
|
result += newinterv.milliseconds / 1000
|
||||||
|
|
||||||
proc `+`*(a: TimeInfo, interval: TimeInterval): TimeInfo =
|
proc `+`*(a: TimeInfo, interval: TimeInterval): TimeInfo =
|
||||||
## adds ``interval`` time.
|
## adds ``interval`` time.
|
||||||
|
|
@ -530,7 +535,7 @@ elif defined(JS):
|
||||||
startMilsecs = getTime()
|
startMilsecs = getTime()
|
||||||
|
|
||||||
proc getStartMilsecs(): int =
|
proc getStartMilsecs(): int =
|
||||||
## get the miliseconds from the start of the program
|
## get the milliseconds from the start of the program
|
||||||
return int(getTime() - startMilsecs)
|
return int(getTime() - startMilsecs)
|
||||||
|
|
||||||
proc valueOf(time: Time): float {.importcpp: "getTime", tags:[]}
|
proc valueOf(time: Time): float {.importcpp: "getTime", tags:[]}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,10 @@ News
|
||||||
Changes affecting backwards compatibility
|
Changes affecting backwards compatibility
|
||||||
-----------------------------------------
|
-----------------------------------------
|
||||||
|
|
||||||
|
- The ``miliseconds`` property of ``times.TimeInterval`` is now ``milliseconds``.
|
||||||
|
Code accessing that property is deprecated and code using ``miliseconds``
|
||||||
|
during object initialization or as a named parameter of ``initInterval()``
|
||||||
|
will need to be updated.
|
||||||
|
|
||||||
Language Additions
|
Language Additions
|
||||||
------------------
|
------------------
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue