Get system time

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

Get system time

Post by Annik » Mon Mar 24, 2014 11:38 am

Is there any way to get the current time of the system from within the nrniv window? Something akin to localtime() in C?

ted
Site Admin
Posts: 5509
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Get system time

Post by ted » Mon Mar 24, 2014 12:47 pm

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.
viewtopic.php?f=28&t=1955

Post Reply