summary refs log tree commit diff stats
path: root/lib/system.nim
diff options
context:
space:
mode:
authorDominik Picheta <dominikpicheta@googlemail.com>2012-05-26 01:52:43 +0100
committerDominik Picheta <dominikpicheta@googlemail.com>2012-05-26 01:52:43 +0100
commit25ea5c35b8ee8761f82b844cc11a8051015e541a (patch)
tree0c44b0c8c9184f92cb6e3f8a5902eb612781c0e4 /lib/system.nim
parent848c1b297f8f45fd3b69c3886e8328b738def0be (diff)
downloadNim-25ea5c35b8ee8761f82b844cc11a8051015e541a.tar.gz
Added timezone handling and functions for adding and subtracting time to the times module. Added insert for strings to the system
module.
Diffstat (limited to 'lib/system.nim')
-rwxr-xr-xlib/system.nim13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/system.nim b/lib/system.nim
index 148df7e34..0c6aea750 100755
--- a/lib/system.nim
+++ b/lib/system.nim
@@ -2290,5 +2290,18 @@ template eval*(blk: stmt): stmt =
     macro payload(x: stmt): stmt = blk
     payload()
 
+proc insert*(x: var string, item: string, i = 0) {.noSideEffect.} = 
+  ## inserts `item` into `x` at position `i`.
+  var xl = x.len
+  setLen(x, xl+item.len)
+  var j = xl-1
+  while j >= i:
+    shallowCopy(x[j+item.len], x[j])
+    dec(j)
+  j = 0
+  while j < item.len:
+    x[j+i] = item[j]
+    inc(j)
+
 when defined(initDebugger):
   initDebugger()