Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
timelite
Advanced tools
Readme
String date and time utilities.
Time
add
: Add an array of string times. Eg. add(['04:20:10', '21:15:10'])
str
: Format an array of time values into string time. Eg. str([12, 0, 45])
=> [ 12, 00, 45 ]
sub
: Subtract an array of string times. Eg. sub(['20:05:10', '10:10:50'])
=> [ 9, 54, 20 ]
Date
normalize
: Normalize string date values returning a valid date as an unsigned integer array.str
: Format an array date values into a valid string date.yarn add timelite --dev
npm install timelite --save-dev
UMD file is also available on unpkg:
<script src="https://unpkg.com/timelite/timelite.umd.min.js"></script>
You can use the library via window.timelite
.
Add an array of string time values "HH:mm:ss".
import { add } from 'timelite/time'
add(['04:20:10', '21:15:10'])
// [ 25, 35, 2 ]
add(['04:35:10', '21:35:10'])
// [ 26, 10, 2 ]
add(['30:59', '17:10'])
// [ 48, 09, 0 ]
add(['19:30:00', '00:30:00'])
// [ 20, 00, 0 ]
Subtract an array of string time values "HH:mm:ss".
import { sub } from 'timelite/time'
sub(['20:40:10', '20:10:50'])
// [ 0, 29, 20 ]
sub(['20:05:10', '10:10:50'])
// [ 9, 54, 20 ]
Format an array time values into string time.
import { str } from 'timelite/time'
str([12, 10, 45])
// "12:10:45"
str([5, 1, 0])
// "05:01:00"
str([7, 22])
// "07:22:00"
Normalize string date values returning a valid date as an unsigned integer array.
import { normalize } from 'timelite/date'
normalize('1980-09-02')
// [ 1980, 9, 2 ]
normalize('17')
// [ 2017, 1, 1 ]
normalize('18-04')
// [ 2018, 4, 1 ]
normalize('0-02-31')
// [ 2000, 2, 28 ]
Format an array date values into a valid string date.
import { str } from 'timelite/date'
str([ 0, 0, 0 ])
// 2000-01-01
str([ 17, 14, 5 ])
// 2017-12-05
str([ 1988, 2 ])
// 1988-02-01
Feel free to send some Pull request or issue.
MIT license
© 2018 José Luis Quintana
FAQs
String date and time utilities
The npm package timelite receives a total of 112 weekly downloads. As such, timelite popularity was classified as not popular.
We found that timelite demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.