mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 05:50:30 +00:00
Fixed math.round, added math.ceil and fixed times.format.
This commit is contained in:
@@ -192,7 +192,7 @@ __clang__
|
||||
** long int lrint (double x);
|
||||
*/
|
||||
|
||||
#if defined(__LCC__) || (defined(__GNUC__) && defined(WIN32))
|
||||
#if defined(__LCC__) || (defined(__GNUC__))
|
||||
/* Linux' GCC does not seem to have these. Why? */
|
||||
# define HAVE_LRINT
|
||||
# define HAVE_LRINTF
|
||||
|
||||
@@ -186,10 +186,12 @@ when not defined(ECMAScript):
|
||||
|
||||
proc trunc*(x: float): float {.importc: "trunc", nodecl.}
|
||||
proc floor*(x: float): float {.importc: "floor", nodecl.}
|
||||
proc ceil*(x: float): float {.importc: "ceil", nodecl.}
|
||||
|
||||
else:
|
||||
proc mathrandom(): float {.importc: "Math.random", nodecl.}
|
||||
proc floor*(x: float): float {.importc: "Math.floor", nodecl.}
|
||||
proc ceil*(x: float): float {.importc: "Math.ceil", nodecl.}
|
||||
proc random*(max: int): int = return int(floor(mathrandom() * float(max)))
|
||||
proc randomize*() = nil
|
||||
|
||||
|
||||
@@ -557,9 +557,9 @@ proc format*(info: TTimeInfo, f: string): string =
|
||||
result.add("0")
|
||||
result.add($info.monthday)
|
||||
of "ddd":
|
||||
result.add(($info.monthday)[0 .. 2])
|
||||
result.add(($info.weekday)[0 .. 2])
|
||||
of "dddd":
|
||||
result.add($info.monthday)
|
||||
result.add($info.weekday)
|
||||
of "h":
|
||||
result.add($(info.hour - 12))
|
||||
of "hh":
|
||||
|
||||
Reference in New Issue
Block a user