mirror of
https://github.com/samsonjs/strftime.git
synced 2026-04-27 14:57:37 +00:00
try to fix syntax highlighting on GitHub
This commit is contained in:
parent
30fd95dbba
commit
1d4365f3d5
2 changed files with 10 additions and 3 deletions
|
|
@ -14,6 +14,7 @@ The headline feature is a huge performance boost resulting from [this contest](h
|
||||||
|
|
||||||
Along with this the API has been unified and cleaned up. `strftimeTZ`, `strftimeUTC`, and `localizedStrftime` have all been deprecated in favour of the following functions: `timezone(tz)`, `utc()`, and `localize(locale)`. You use them like so:
|
Along with this the API has been unified and cleaned up. `strftimeTZ`, `strftimeUTC`, and `localizedStrftime` have all been deprecated in favour of the following functions: `timezone(tz)`, `utc()`, and `localize(locale)`. You use them like so:
|
||||||
|
|
||||||
|
```JavaScript
|
||||||
var strftime = require('strftime'); // not required in web browsers
|
var strftime = require('strftime'); // not required in web browsers
|
||||||
|
|
||||||
var strftimeIT = strftime.localize(anItalianLocale);
|
var strftimeIT = strftime.localize(anItalianLocale);
|
||||||
|
|
@ -25,6 +26,7 @@ Along with this the API has been unified and cleaned up. `strftimeTZ`, `strftime
|
||||||
|
|
||||||
// And chain them all at once
|
// And chain them all at once
|
||||||
var strftimeIT_PST = strftime.localize(anItalianLocale).timezone('-0800');
|
var strftimeIT_PST = strftime.localize(anItalianLocale).timezone('-0800');
|
||||||
|
```
|
||||||
|
|
||||||
The previous API is deprecated and will be removed for v1.0. The good news is that the previous API is supported by adapting the new API, so you get most of the performance benefits before you even update your code to use the new API.
|
The previous API is deprecated and will be removed for v1.0. The good news is that the previous API is supported by adapting the new API, so you get most of the performance benefits before you even update your code to use the new API.
|
||||||
|
|
||||||
|
|
|
||||||
11
Readme.md
11
Readme.md
|
|
@ -33,13 +33,16 @@ Now you only need the single object exported and you can create a specialized ve
|
||||||
Usage
|
Usage
|
||||||
=====
|
=====
|
||||||
|
|
||||||
|
```JavaScript
|
||||||
var strftime = require('strftime') // not required in browsers
|
var strftime = require('strftime') // not required in browsers
|
||||||
console.log(strftime('%B %d, %Y %H:%M:%S')) // => April 28, 2011 18:21:08
|
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
|
console.log(strftime('%F %T', new Date(1307472705067))) // => 2011-06-07 18:51:45
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
If you want to localize it:
|
If you want to localize it:
|
||||||
|
|
||||||
|
```JavaScript
|
||||||
var strftime = require('strftime') // not required in browsers
|
var strftime = require('strftime') // not required in browsers
|
||||||
var it_IT = {
|
var it_IT = {
|
||||||
days: ['domenica', 'lunedi', 'martedi', 'mercoledi', 'giovedi', 'venerdi', 'sabato'],
|
days: ['domenica', 'lunedi', 'martedi', 'mercoledi', 'giovedi', 'venerdi', 'sabato'],
|
||||||
|
|
@ -65,25 +68,27 @@ If you want to localize it:
|
||||||
var strftimeIT = strftime.localize(it_IT)
|
var strftimeIT = strftime.localize(it_IT)
|
||||||
console.log(strftimeIT('%B %d, %Y %H:%M:%S')) // => aprile 28, 2011 18:21:08
|
console.log(strftimeIT('%B %d, %Y %H:%M:%S')) // => aprile 28, 2011 18:21:08
|
||||||
console.log(strftimeIT('%B %d, %Y %H:%M:%S', new Date(1307472705067))) // => giugno 7, 2011 18:51:45
|
console.log(strftimeIT('%B %d, %Y %H:%M:%S', new Date(1307472705067))) // => giugno 7, 2011 18:51:45
|
||||||
|
```
|
||||||
|
|
||||||
Time zones can be passed in as an offset from GMT in minutes.
|
Time zones can be passed in as an offset from GMT in minutes.
|
||||||
|
|
||||||
|
```JavaScript
|
||||||
var strftime = require('strftime') // not required in browsers
|
var strftime = require('strftime') // not required in browsers
|
||||||
var strftimePDT = strftime.timezone(-420)
|
var strftimePDT = strftime.timezone(-420)
|
||||||
var strftimeCEST = strftime.timezone(120)
|
var strftimeCEST = strftime.timezone(120)
|
||||||
console.log(strftimePDT('%B %d, %y %H:%M:%S', new Date(1307472705067))) // => June 07, 11 11:51:45
|
console.log(strftimePDT('%B %d, %y %H:%M:%S', new Date(1307472705067))) // => June 07, 11 11:51:45
|
||||||
console.log(strftimeCEST('%F %T', new Date(1307472705067))) // => 2011-06-07 20:51:45
|
console.log(strftimeCEST('%F %T', new Date(1307472705067))) // => 2011-06-07 20:51:45
|
||||||
|
```
|
||||||
|
|
||||||
Alternatively you can use the timezone format used by ISO 8601, `+HHMM` or `-HHMM`.
|
Alternatively you can use the timezone format used by ISO 8601, `+HHMM` or `-HHMM`.
|
||||||
|
|
||||||
|
```JavaScript
|
||||||
var strftime = require('strftime') // not required in browsers
|
var strftime = require('strftime') // not required in browsers
|
||||||
var strftimePDT = strftime.timezone('-0700')
|
var strftimePDT = strftime.timezone('-0700')
|
||||||
var strftimeCEST = strftime.timezone('+0200')
|
var strftimeCEST = strftime.timezone('+0200')
|
||||||
console.log(strftimePDT('', new Date(1307472705067))) // => June 07, 11 11:51:45
|
console.log(strftimePDT('', new Date(1307472705067))) // => June 07, 11 11:51:45
|
||||||
console.log(strftimeCEST('%F %T', new Date(1307472705067))) // => 2011-06-07 20:51:45
|
console.log(strftimeCEST('%F %T', new Date(1307472705067))) // => 2011-06-07 20:51:45
|
||||||
|
```
|
||||||
|
|
||||||
Supported Specifiers
|
Supported Specifiers
|
||||||
====================
|
====================
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue