Meteor-Community-Packages / meteor-timesync

NTP-style time synchronization between server and client, and facilities to use server time reactively in Meteor applications.
https://packosphere.com/mizzao/timesync
MIT License
118 stars 36 forks source link

Type of TimeSync.serverTime() with fixed date #23

Closed steph643 closed 9 years ago

steph643 commented 9 years ago

Here is what I get:

console.log(typeof TimeSync.serverTime(new Date));
console.log(typeof TimeSync.serverTime());
string
number

Am I not supposed to get a Date?

(dammit, I keep forgetting I am a programmer!)

mizzao commented 9 years ago

The first one seems to be a bug, I'll look into it.

The second is a unix epoch, which you can convert into a Date with new Date(TimeSync.serverTime(...))

Since the date is calculated by adding an offset to an epoch, I decided not to construct a new date automatically. But that could be changed...

steph643 commented 9 years ago

Thanks a lot. In my opinion, there is no need for serverTime() to return a Date object as long as you put your explanation in the doc.

mizzao commented 9 years ago

This is now fixed in the (just released) 0.3.1.

steph643 commented 9 years ago

Works well, thanks!