mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-12 04:50:18 +00:00
[calendar] Add types for calendar (#40322)
This commit is contained in:
committed by
Pranav Senthilnathan
parent
4148f3afa9
commit
2dbf2e48ba
@@ -0,0 +1,16 @@
|
||||
import { Calendar } from 'calendar';
|
||||
|
||||
const cal = new Calendar();
|
||||
cal.monthText(2019, 11);
|
||||
cal.monthText();
|
||||
|
||||
const now = new Date();
|
||||
const year = now.getFullYear();
|
||||
const month = now.getMonth();
|
||||
|
||||
cal.monthDates(
|
||||
year,
|
||||
month,
|
||||
date => date.getMonth() === month ? date.getDate().toString() : ' ',
|
||||
week => week.join('</td><td>'),
|
||||
);
|
||||
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
// Type definitions for calendar 0.1
|
||||
// Project: https://github.com/ramalho/calendar.js#readme
|
||||
// Definitions by: Florian Keller <https://github.com/ffflorian>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export type DayFormatter = (day: Date) => Date | string;
|
||||
export type WeekFormatter = (week: Date[]) => Date[] | string;
|
||||
|
||||
export const version: string;
|
||||
|
||||
export class Calendar {
|
||||
/**
|
||||
* @param firstWeekDay default is `0` (Sunday)
|
||||
*/
|
||||
constructor(firstWeekDay?: number);
|
||||
|
||||
monthDates(year: number, month: number, dayFormatter?: DayFormatter, weekFormatter?: WeekFormatter): Date[];
|
||||
monthDays(year: number, month: number): Date[];
|
||||
monthText(): string;
|
||||
monthText(year: number, month: number): string;
|
||||
weekStartDate(date: Date): Date;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"calendar-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user