@socialize/server-time

1.0.3 • Public • Published

Server Time

A super light weight package to compensate for the difference in time on the server and client.

This is a Meteor package with part of it's code published as a companion NPM package made to work with clients other than Meteor. For example your server is Meteor, but you want to build a React Native app for the client. This allows you to share code between your Meteor server and other clients to give you a competitive advantage when bringing your mobile and web application to market.

Supporting The Project

Finding the time to maintain FOSS projects can be quite difficult. I am myself responsible for over 30 personal projects across 2 platforms, as well as Multiple others maintained by the Meteor Community Packages organization. Therfore, if you appreciate my work, I ask that you either sponsor my work through GitHub, or donate via Paypal or Patreon. Every dollar helps give cause for spending my free time fielding issues, feature requests, pull requests and releasing updates. Info can be found in the "Sponsor this project" section of the GitHub Repo

Meteor Installation

meteor add socialize:server-time

NPM Installation

npm install --save @socialize/server-time

Usage Outside Meteor

The client side parts of this package are published to NPM as @socialize/server-time for use in front ends outside of Meteor.

When using the npm package you'll need to connect to a server, which hosts the server side Meteor code for your app, using Meteor.connect as per the @socialize/react-native-meteor usage example documentation.

Meteor.connect('ws://192.168.X.X:3000/websocket');

React Native

When using this package with React Native there is some minor setup required by the @socialize/react-native-meteor package. See @socialize/react-native-meteor react-native for necessary instructions.

API

ServerTime.now() - returns a difference compensated timestamp representing the current time on the server.

ServerTime.date() - returns a difference compensated Date() object representing the current date on the server.

Usage Example

// Meteor
import { ServerTime } from 'meteor/socialize:server-time';
// React
import { ServerTime } from 'meteor/socialize:server-time';
let compensatedDate = ServerTime.date();

Package Sidebar

Install

npm i @socialize/server-time

Weekly Downloads

1

Version

1.0.3

License

MIT

Unpacked Size

9.61 kB

Total Files

14

Last publish

Collaborators

  • copleykj