Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
strftime for JavaScript, works in Node.js and browsers, supports localization. Most standard specifiers from C are supported as well as some other extensions from Ruby.
npm install strftime
var strftime = require('strftime')
console.log(strftime('%B %d, %y %H:%M:%S')) // => April 28, 2011 18:21:08
console.log(strftime('%F %T', new Date(1307472705067))) // => 2011-06-07 18:51:45
If you want to localize it:
var strftime = require('strftime')
var it_IT = {
days: [ 'domenica', 'lunedi', 'martedi', 'mercoledi', 'giovedi', 'venerdi', 'sabato' ],
shortDays: [ 'dom', 'lun', 'mar', 'mer', 'gio', 'ven', 'sab' ],
months: [ 'gennaio', 'febbraio', 'marzo', 'aprile', 'maggio', 'giugno', 'luglio',
'agosto', 'settembre', 'ottobre', 'novembre', 'dicembre' ],
shortMonths: [ 'gen', 'feb', 'mar', 'apr', 'mag', 'giu', 'lug', 'ago',
'set', 'ott', 'nov', 'dic' ],
AM: 'AM',
PM: 'PM'
}
console.log(strftime('%B %d, %y %H:%M:%S', it_IT)) // => aprile 28, 2011 18:21:08
console.log(strftime('%B %d, %y %H:%M:%S', new Date(1307472705067), it_IT)) // => giugno 7, 2011 18:51:45
And if you don't want to pass a localization object every time you can get a localized strftime
function like so:
var strftime = require('strftime')
var it_IT = { /* same as above */ }
var strftime_IT = strftime.localizedStrftime(it_IT)
console.log(strftime_IT('%B %d, %y %H:%M:%S')) // aprile 28, 2011 18:21:08
Extensions from Ruby are noted in the following list.
Unsupported specifiers are rendered without the percent sign.
e.g. %q
becomes q
. Use %%
to get a literal %
sign.
%m/%d/%y
%Y-%m-%d
%H:%M
%I:%M:%S %p
%H:%M:%S
%e-%b-%Y
For more detail see man 3 strftime
as the format specifiers should behave identically. If behaviour differs please file a bug.
Copyright 2010 - 2013 Sami Samhuri sami@samhuri.net
MIT (see included LICENSE)
FAQs
strftime for JavaScript
We found that strftime demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.