summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-time/src/time.c
diff options
context:
space:
mode:
authorPaolo Bosetti <[email protected]>2015-11-27 10:54:03 +0100
committerPaolo Bosetti <[email protected]>2015-11-27 10:54:03 +0100
commit67e3cdfa76f072e52d76b6535587adccda310f4e (patch)
tree8cbdc7284e115e278f8de46618ecc250187e6a60 /mrbgems/mruby-time/src/time.c
parent9a41db6f3a98eef636e94698d7f378feb03e8e0b (diff)
downloadmruby-67e3cdfa76f072e52d76b6535587adccda310f4e.tar.gz
mruby-67e3cdfa76f072e52d76b6535587adccda310f4e.zip
Implemented round(double) function within mruby-time gem, for it is missing on
VisualStudio compilers where _MSC_ver < 1800
Diffstat (limited to 'mrbgems/mruby-time/src/time.c')
-rw-r--r--mrbgems/mruby-time/src/time.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/mrbgems/mruby-time/src/time.c b/mrbgems/mruby-time/src/time.c
index 2a4347b7c..b9746b79e 100644
--- a/mrbgems/mruby-time/src/time.c
+++ b/mrbgems/mruby-time/src/time.c
@@ -11,6 +11,16 @@
#include <mruby/class.h>
#include <mruby/data.h>
+#if _MSC_VER < 1800
+double round(double x) {
+ if (x >= 0.0) {
+ return (double)((int)(x + 0.5));
+ } else {
+ return (double)((int)(x - 0.5));
+ }
+}
+#endif
+
#if !defined(__MINGW64__) && defined(_WIN32)
# define llround(x) round(x)
#endif