Skip to content

Commit 098eaef

Browse files
committed
Update README
1 parent 0127fe1 commit 098eaef

File tree

1 file changed

+31
-11
lines changed

1 file changed

+31
-11
lines changed

README.md

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,30 +35,50 @@ Using cdn
3535
<script src="https://unpkg.com/quartzite/dist/quartzite.js"></script>
3636
```
3737

38-
## Usage
38+
## Example
39+
40+
Importing as ES6 module
3941

4042
```javascript
4143
import * as quartzite from 'quartzite';
44+
```
4245

43-
const date = new Date();
46+
or using CommonJS
47+
48+
```javascript
49+
const quartzite = require('quartzite');
50+
```
4451

45-
// Create date in the past
52+
Create date in the past
53+
54+
```javascript
55+
const date = new Date();
4656
const yesterday = quartzite.dateByAdding('hours', date, -25);
57+
```
58+
59+
Create date in the future
4760

48-
// Create date in the future
61+
```javascript
62+
const date = new Date();
4963
const someday = quartzite.dateByAdding('days', date, 5);
64+
```
5065

51-
// Format date using medium style
52-
// Will return 'Just now', '5 hours ago', 'Yesterday'
53-
console.log(quartzite.dateString(yesterday));
66+
Format date using `medium` style
67+
68+
```javascript
69+
console.log(quartzite.dateString(yesterday)); // Medium is the default option
5470
console.log(quartzite.dateString(someday, 'medium'));
71+
```
5572

56-
// Format date using short style
57-
// Will return '20m', '2d', 'Feb 7', '8 Aug 2017'
73+
Format date using `short` style
74+
75+
```javascript
5876
console.log(quartzite.dateString(someday, 'short'));
77+
```
5978

60-
// Format date using long style
61-
// Will return 'Today, 20:15', 'Friday, 22:30', 'Tuesday, November 5th'
79+
Format date using `long` style
80+
81+
```javascript
6282
console.log(quartzite.dateString(someday, 'long'));
6383
```
6484

0 commit comments

Comments
 (0)