Parse Times
Parsing waktu dan dapatkan result yang komplit!
Menggunakan library dari MomentJs.
List of Function :
- getTime()
// get => waktu saat ini => Objcet
- getWeton()
// get => weton berdasarkan waktu => String
- getTimeById()
// get => waktu berdasarkan id => Objcet
- getRelative()
// get => Realtive waktu => String
- getCalendar()
// get => Calendar waktu => String
Installation
Install with npm:
$ npm install parse-times
With require:
const parseTimes = require("parse-times");
Usage
Example :
see example.js for details.
Set Locale Time
if you want to change the region, you must read the documentation MomentJs.
parseTimes.set('id')
Get default Time
const getTime = parseTimes.getTime()
const getTimeFormat = parseTimes.getTime({format: "DD/MM/YYYY hh:mm:ss a"})
const timeId = new Date().getTime() || 1668343818991
const getTimeById = parseTimes.getTimeById(timeId)
const getTimeByIdFormat = parseTimes.getTimeById(timeId, {format: "DD/MM/YYYY hh:mm:ss a"})
Get Weton
const getWeton = parseTimes.getWeton(17, 11, 2022)
Get Relative Time
const timeId = new Date().getTime() || 1668343818991
const getRelativeById = parseTimes.getRelative(timeId)
const getRelativeBySeconds = parseTimes.getRelative(timeId, {input: 10, based: 'seconds'})
const getRelativeMinutes = parseTimes.getRelative(timeId, {input: 10, based: 'minutes'})
const getRelativeHours = parseTimes.getRelative(timeId, {input: 10, based: 'hours'})
const getRelativeDays = parseTimes.getRelative(timeId, {input: 10, based: 'days'})
const getRelativeMonths = parseTimes.getRelative(timeId, {input: 10, based: 'months'})
const getRelativeYears = parseTimes.getRelative(timeId, {input: 10, based: 'years'})
Get Calendar Time
const timeId = new Date().getTime() || 1668343818991
const getCalendarById = parseTimes.getCalendar(timeId)
const getCalendarBySeconds = parseTimes.getCalendar(timeId, {input: 10, based: 'seconds'})
const getCalendarMinutes = parseTimes.getCalendar(timeId, {input: 10, based: 'minutes'})
const getCalendarHours = parseTimes.getCalendar(timeId, {input: 10, based: 'hours'})
const getCalendarDays = parseTimes.getCalendar(timeId, {input: 10, based: 'days'})
const getCalendarMonths = parseTimes.getCalendar(timeId, {input: 10, based: 'months'})
const getCalendarYears = parseTimes.getCalendar(timeId, {input: 10, based: 'years'})
Testing
Install dependencies:
npm install
Run tests:
npm run test
License
Code released under the Apache license.