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.
date-format-lite
Advanced tools
Readme
@version 17.7.0
@date 2017-07-14
@stability 2 - Unstable
A small library for parsing and formatting dates that extends native Date object.
npm install date-format-lite --save
require("date-format-lite")
date-format-lite
adds format(mask, [zone])
method to native Date.prototype
.
String
- Output format, e.g. hh:mm:ss
.Number, optional
- UTC offset in hours, e.g. -6.5
.var now = new Date() // Date {Wed Jul 10 2013 16:47:36 GMT+0300 (EEST)}
now.format("iso") // 2013-07-10T13:47:36Z
now.format("hh:mm") // 16:47 (local time)
now.format("UTC:hh:mm") // 13:47
now.format("hh:mm", 2.5) // 16:17
date-format-lite
adds add(amount, [unit])
method to native Date.prototype
.
Number
- Time to add, negative number will be subtracted.String, optional
- e.g. seconds, minutes, hours, days, weeks, months, years.now.format("iso") // 2013-07-10T13:47:36Z
now.add(1, "days").format("iso") // 2013-07-11T13:47:36Z
now.add(-2, "hours").format("iso") // 2013-07-11T11:47:36Z
date-format-lite
adds date([outFormat], [outZone], [inZone])
method
to native String.prototype
and Number.prototype
.
String, optional
- Output format, e.g. hh:mm:ss
.
Returns date object when format not specified.Number, optional
- UTC offset for output in hours, e.g. -6.5
.Number, optional
- UTC offset in input in hours, e.g. -6.5
."2013-07-10".date() // Date {Wed Jul 10 2013 03:00:00 GMT+0300 (EEST)}
"2013-07-10T13:47:36Z".date() // Date {Wed Jul 10 2013 16:47:36 GMT+0300 (EEST)}
"10/07/2013".date() // Date {Wed Jul 10 2013 03:00:00 GMT+0300 (EEST)}
Date.middleEndian = true
"10/07/2013".date() // Date {Mon Oct 07 2013 03:00:00 GMT+0300 (EEST)}
// Change format
"10/07/2013".date("YYYY-MM-DD")// 2013-07-10
Date.masks.my = '"DayNo "D'
now.format("my") // DayNo 10
Date.masks.default = 'YYYY-MM-DD hh:mm:ss'
now.format() // 2013-07-10 13:47:36
// Add to estonian-lang.js
Date.names = "Jaan Veeb Märts Apr Mai Juuni Juuli Aug Sept Okt Nov Dets jaanuar veebruar märts aprill mai juuni juuli august september oktoober november detsember P E T K N R L pühapäev esmaspäev teisipäev kolmapäev neljapäev reede laupäev".split(" ")
// Change AM and PM
Date.am = "a.m."
Date.pm = "p.m."
See tests for more examples
It should work IE6 and up but automated testing is currently broken.
Copyright (c) 2012-2016 Lauri Rooden <lauri@rooden.ee>
The MIT License
FAQs
A small library for parsing and formatting dates
The npm package date-format-lite receives a total of 1,123 weekly downloads. As such, date-format-lite popularity was classified as popular.
We found that date-format-lite 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.