Skip to content

Commit

Permalink
Merge pull request #172 from BendingBender/patch-1
Browse files Browse the repository at this point in the history
Fix examples in readme for ES6 style imports
  • Loading branch information
chase-manning committed Oct 16, 2021
2 parents d91ac96 + 86b7df3 commit 6cf7a7c
Showing 1 changed file with 50 additions and 49 deletions.
99 changes: 50 additions & 49 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ $ dateformat --help
As taken from Steven's post, modified to match the Modifications listed above:

```js
import dateFormat from "dateformat";
var now = new Date();
import dateFormat, { masks } from "dateformat";
const now = new Date();

// Basic usage
dateFormat(now, "dddd, mmmm dS, yyyy, h:MM:ss TT");
Expand All @@ -32,7 +32,7 @@ dateFormat(now, "isoDateTime");
// 2007-06-09T17:46:21

// ...Or add your own
dateFormat.masks.hammerTime = 'HH:MM! "Can\'t touch this!"';
masks.hammerTime = 'HH:MM! "Can\'t touch this!"';
dateFormat(now, "hammerTime");
// 17:46! Can't touch this!

Expand Down Expand Up @@ -137,52 +137,53 @@ Day names, month names and the AM/PM indicators can be localized by
passing an object with the necessary strings. For example:

```js
import dateFormat from "dateformat";
dateFormat.i18n = {
dayNames: [
"Sun",
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat",
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday",
],
monthNames: [
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec",
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December",
],
timeNames: ["a", "p", "am", "pm", "A", "P", "AM", "PM"],
};
import { i18n } from "dateformat";

i18n.dayNames = [
"Sun",
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat",
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday",
];

i18n.monthNames = [
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec",
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December",
];

i18n.timeNames = ["a", "p", "am", "pm", "A", "P", "AM", "PM"];
```

> Notice that only one language is supported at a time and all strings
Expand Down

0 comments on commit 6cf7a7c

Please sign in to comment.