Get system time

Anything that doesn't fit elsewhere.
Post Reply
Posts: 27
Joined: Fri Sep 07, 2012 1:02 pm

Get system time

Post by Annik »

Is there any way to get the current time of the system from within the nrniv window? Something akin to localtime() in C?
Site Admin
Posts: 5795
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine

Re: Get system time

Post by ted »

hoc has a system() call but it its arguments and returned results are guaranteed to be non-portable because they depend on one's operating system. It is a bad idea to make one's code OS-dependent, because you will be creating future problems for any one who tries to reuse it under a different OS.

hoc also has startsw and stopsw, but the chief utility of those functions is for gauging software performance. If you're thinking about using those values as seeds for pseudorandom number generators, don't. That may be appropriate for a computer game, or for a demonstration program that produces flashy effects, but it's not a good idea for computational modeling--see this strong caveat.
Post Reply