TimesJs
Dapatkan waktu lengkap dalam bentuk json maupun string.
Menggunakan library dari MomentJs.
List of Function :
- getTime()
// Mendapatkan waktu saat ini => Objcet
- getWeton()
// Mendapatkan weton berdasarkan waktu => String
- getTimeById()
// Mendapatkan waktu berdasarkan id => Objcet
- getRelative()
// Mendapatkan Realtive waktu => String
- getCalendar()
// Mendapatkan Calendar waktu => String
Installation
Install with npm:
$ npm install timesJs
With require:
const timeJs = require("timeJs");
Usage
Example :
see example.js for details.
Get default Time
const getTime = moment.getTime()
const getTimeFormat = moment.getTime({format: "DD/MM/YYYY hh:mm:ss a"})
const timeId = new Date().getTime() || 1668343818991
const getTimeById = moment.getTimeById(timeId)
const getTimeByIdFormat = moment.getTimeById(timeId, {format: "DD/MM/YYYY hh:mm:ss a"})
Get Weton
const getWeton = moment.getWeton(17, 11, 2022)
Get Relative Time
const timeId = new Date().getTime() || 1668343818991
const getRelativeById = moment.getRelative(timeId)
const getRelativeBySeconds = moment.getRelative(timeId, {input: 10, based: 'seconds'})
const getRelativeMinutes = moment.getRelative(timeId, {input: 10, based: 'minutes'})
const getRelativeHours = moment.getRelative(timeId, {input: 10, based: 'hours'})
const getRelativeDays = moment.getRelative(timeId, {input: 10, based: 'days'})
const getRelativeMonths = moment.getRelative(timeId, {input: 10, based: 'months'})
const getRelativeYears = moment.getRelative(timeId, {input: 10, based: 'years'})
Get Calendar Time
const timeId = new Date().getTime() || 1668343818991
const getCalendarById = moment.getCalendar(timeId)
const getCalendarBySeconds = moment.getCalendar(timeId, {input: 10, based: 'seconds'})
const getCalendarMinutes = moment.getCalendar(timeId, {input: 10, based: 'minutes'})
const getCalendarHours = moment.getCalendar(timeId, {input: 10, based: 'hours'})
const getCalendarDays = moment.getCalendar(timeId, {input: 10, based: 'days'})
const getCalendarMonths = moment.getCalendar(timeId, {input: 10, based: 'months'})
const getCalendarYears = moment.getCalendar(timeId, {input: 10, based: 'years'})
Testing
Install dependencies:
npm install
Run tests:
npm run test
License
Code released under the Apache license.