1.0.8 • Published 6 years ago

simplertime v1.0.8

Weekly downloads
4
License
ISC
Repository
github
Last release
6 years ago

"simplertime" time-of-day library

Parses and prints time values stored as Date or number (number of milliseconds since midnight).

  • 1.6KB minified
  • Parses many formats: 12, 1234, 12:34, 12:34pm, 12:34 PM, 12:34:56 pm, 12:34:56.789
  • Understands UTC and local time
  • Full documentation is in the source code (for IntelliSense).

Example

import { parseTime, timeToString, timeToStringUTC } from 'simplertime';

var now = Date.now();
console.log("Local time (24-hour clock, no seconds): " + 
            timeToString(now, {use24hourTime: true, showSeconds: false}));
console.log("Local time (12-hour clock with seconds): " +
            timeToString(now, {showSeconds: true}));

var fmt = {
  am: " in the morning", 
  pm: " in the afternoon", 
  evening: " at night"
};
var later = now + parseTime("7:15"); // add 7 hours and 15 minutes
console.log("Seven hours and 15 minutes later is " + timeToString(later, fmt));
console.log("Which in UTC time is .............. " + timeToStringUTC(later, fmt));
console.log("Noon UTC converted to local time is " +
            timeToString(parseTime("12PM"), fmt));
console.log("Noon local time converted to UTC is " +
            timeToStringUTC(parseTime("12PM", new Date()), fmt));

♥ This package was made to help people learn TypeScript & React.

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago