TooTallNate / node-time

"time.h" bindings for Node.js
MIT License
382 stars 84 forks source link

Set time function #95

Open infusion opened 8 years ago

infusion commented 8 years ago

Hi,

could you please add a binding to stime(), which sets the system time to a provided Date object. This comes in handy on devices without a RTC, like raspberry pi or similar. I'd like to use npm's gps module, which holds Date objects of the received time and update the system time like this:

function onData(data) {
   time.stime(data.time);
}

Thanks!

TooTallNate commented 8 years ago

I can't find this function on OS X. Do you have a man page for this function?

On Sun, May 29, 2016 at 5:09 AM, Robert Eisele notifications@github.com wrote:

Hi,

could you please add a binding to stime(), which sets the system time to a provided Date object. This comes in handy on devices without a RTC, like raspberry pi or similar. I'd like to use npm's gps module, which holds Date objects of the received time and update the system time like this:

function onData(data) { time.stime(data.time); }

Thanks!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/TooTallNate/node-time/issues/95, or mute the thread https://github.com/notifications/unsubscribe/AAEWWK1pcaTQCXpJwvRp55_mqwPdFooKks5qGYIBgaJpZM4IpRs0 .

infusion commented 8 years ago

Yep sure: http://linux.die.net/man/2/stime A similar API is settimeofday: http://linux.die.net/man/2/settimeofday But I'm not sure about OSX, I think their policy restricts changing the time.

Update: OSX has settimeofday as well: https://developer.apple.com/library/ios/documentation/System/Conceptual/ManPages_iPhoneOS/man2/settimeofday.2.html