json-calendar
Advanced tools
Comparing version 1.7.1 to 1.8.20
{ | ||
"name": "json-calendar", | ||
"version": "1.7.1", | ||
"version": "1.8.20", | ||
"description": "A data model for displaying dates and date ranges on a calendar interface.", | ||
@@ -12,12 +12,22 @@ "keywords": [ | ||
], | ||
"homepage": "https://github.com/rxgx/json-calendar", | ||
"homepage": "https://github.com/turbo-io/json-calendar", | ||
"license": "MIT", | ||
"author": "Ryan Gasparini <ryan@rxgx.com> (http://www.rxgx.com)", | ||
"bugs": { | ||
"url": "https://github.com/rxgx/json-calendar/issues" | ||
"url": "https://github.com/turbo-io/json-calendar/issues" | ||
}, | ||
"main": "src/index.js", | ||
"main": "./lib/index.js", | ||
"module": "./lib/index.js", | ||
"types": "./lib/index.d.ts", | ||
"directories": { | ||
"lib": "./lib" | ||
}, | ||
"files": [ | ||
"lib/**/*" | ||
], | ||
"scripts": { | ||
"lint": "eslint src/*.js", | ||
"test": "TZ=America/Phoenix jest", | ||
"build": "tsc", | ||
"format": "standardx --fix **/*.ts", | ||
"lint": "standardx **/*.ts", | ||
"test": "jest", | ||
"verify": "npm run lint && npm t" | ||
@@ -27,34 +37,40 @@ }, | ||
"type": "git", | ||
"url": "https://github.com/rxgx/json-calendar.git" | ||
"url": "https://github.com/turbo-io/json-calendar.git" | ||
}, | ||
"devDependencies": { | ||
"eslint": "6.0.1", | ||
"eslint-config-prettier": "6.0.0", | ||
"eslint-plugin-prettier": "3.1.0", | ||
"jest": "24.8.0", | ||
"prettier": "1.18.2" | ||
"@semantic-release/changelog": "^5.0.1", | ||
"@semantic-release/git": "^9.0.0", | ||
"@types/jest": "^26.0.10", | ||
"@typescript-eslint/eslint-plugin": "^3.9.1", | ||
"@typescript-eslint/parser": "^3.9.1", | ||
"jest": "^26.4.2", | ||
"prettier": "2.0.5", | ||
"semantic-release": "^17.1.1", | ||
"standardx": "^5.0.0", | ||
"ts-jest": "^26.2.0", | ||
"typescript": "^4.0.2" | ||
}, | ||
"dependencies": {}, | ||
"eslintConfig": { | ||
"env": { | ||
"es6": true, | ||
"node": true | ||
}, | ||
"extends": [ | ||
"eslint:recommended", | ||
"plugin:prettier/recommended" | ||
"release": { | ||
"branches": [ | ||
"main" | ||
], | ||
"rules": { | ||
"prettier/prettier": "error" | ||
}, | ||
"globals": { | ||
"expect": true, | ||
"test": true, | ||
"describe": true | ||
} | ||
"plugins": [ | ||
"@semantic-release/commit-analyzer", | ||
"@semantic-release/release-notes-generator", | ||
"@semantic-release/changelog", | ||
"@semantic-release/github", | ||
"@semantic-release/npm", | ||
"@semantic-release/git" | ||
] | ||
}, | ||
"jest": { | ||
"collectCoverage": true, | ||
"coverageDirectory": "coverage" | ||
"standardx": { | ||
"parser": "@typescript-eslint/parser", | ||
"plugins": [ | ||
"@typescript-eslint/eslint-plugin" | ||
] | ||
}, | ||
"volta": { | ||
"node": "14.11.0" | ||
} | ||
} |
# json-calendar | ||
[![codecov](https://codecov.io/gh/rxgx/json-calendar/branch/master/graph/badge.svg)](https://codecov.io/gh/rxgx/json-calendar) | ||
[![CircleCI](https://circleci.com/gh/rxgx/json-calendar.svg?style=svg)](https://circleci.com/gh/rxgx/json-calendar) | ||
[![codecov](https://codecov.io/gh/turbo-io/json-calendar/branch/main/graph/badge.svg)](https://codecov.io/gh/turbo-io/json-calendar) | ||
A (JSON) data model for displaying dates and date ranges on a calendar interface. | ||
A JSON data model for displaying dates and date ranges on a calendar interface. | ||
### Usage | ||
## Installation | ||
Install with NodeJS: | ||
```sh | ||
npm install json-calendar | ||
``` | ||
Install for browsers, Volta, or Deno: | ||
```js | ||
var Calendar = require("../index"); | ||
var data = new Calendar(); | ||
import { install } from 'esinstall' | ||
// with custom today date | ||
var = new Calendar({ today: new Date(1971, 0, 1) }); | ||
await install(['json-calendar'], { | ||
/* options */ | ||
}) | ||
// Result: Creates `json-calendar.js` inside a `web_modules/` directory in your current directory. | ||
``` | ||
// with language for days / months name | ||
var calendarWithSpanishNames = new Calendar({ language: 'spanish' | ||
### Usage | ||
/** | ||
* 'french', 'spanish' and 'english' supported, will default to 'english' if empty or unrecognized | ||
*/ | ||
Works default out of the box: | ||
}); | ||
```js | ||
const Calendar = require("json-calendar") | ||
const calendar = new Calendar() | ||
calendar.weeks.map( | ||
week => week.days.map( | ||
day => { | ||
const { className, id, day, date, monthIndex, year } = day; | ||
// do something with the day's data | ||
return date.toLocaleString() | ||
} | ||
) | ||
) | ||
``` | ||
calendarWithSpanishName.dayNames | ||
Or set a custom selected date: | ||
[ 'Domingo', | ||
'Lunes', | ||
'Martes', | ||
'Miércoles', | ||
'Jueves', | ||
'Viernes', | ||
'Sábado' ] | ||
```js | ||
// with custom today date | ||
const calendar = new Calendar({ today: new Date(1971, 0, 1) }) | ||
``` | ||
Or use a specific language: | ||
```js | ||
// with language for day and month names | ||
// 'fr', 'es' and 'en' supported, will default to 'en' if empty or unrecognized | ||
const calendarWithSpanishNames = new Calendar({ languageCode: 'es' }) | ||
``` | ||
For example: | ||
```js | ||
calendarWithSpanishName.dayNames.map(item => console.log(item.name)) | ||
// Outputs: | ||
// 'Domingo' | ||
// 'Lunes' | ||
// 'Martes' | ||
// 'Miércoles' | ||
// 'Jueves' | ||
// 'Viernes' | ||
// 'Sábado' | ||
``` | ||
### Get an array of weeks in this month | ||
```js | ||
console.log("Weeks this month:", data.weeks.length); | ||
console.log("Weeks this month:", calendar.weeks.length) | ||
// Output: Weeks this month: 5 | ||
``` | ||
@@ -47,3 +83,3 @@ | ||
```js | ||
data.weeks.map(w => w.map(d => d.day)); | ||
calendar.weeks.map(w => w.map(d => d.day)) | ||
``` | ||
@@ -67,3 +103,12 @@ | ||
```js | ||
console.log("Month names", data.monthNames); | ||
calendar.monthNames | ||
``` | ||
Will output an array of month names: | ||
```js | ||
[ | ||
'January', 'February', 'March', 'April', 'May', 'June', 'July', | ||
'August', 'September', 'October', 'November', 'December' | ||
] | ||
``` |
Sorry, the diff of this file is too big to display
548819
17
14994
113
11