mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-04 19:42:46 +08:00
add SunCalc definition
This commit is contained in:
49
types/suncalc/index.d.ts
vendored
Normal file
49
types/suncalc/index.d.ts
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
// Type definitions for suncalc 1.8
|
||||
// Project: https://github.com/mourner/suncalc
|
||||
// Definitions by: horiuchi <https://github.com/horiuchi>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export interface GetTimesResult {
|
||||
dawn: Date;
|
||||
dusk: Date;
|
||||
goldenHour: Date;
|
||||
goldenHourEnd: Date;
|
||||
nadir: Date;
|
||||
nauticalDawn: Date;
|
||||
nauticalDusk: Date;
|
||||
night: Date;
|
||||
nightEnd: Date;
|
||||
solarNoon: Date;
|
||||
sunrise: Date;
|
||||
sunriseEnd: Date;
|
||||
sunset: Date;
|
||||
sunsetStart: Date;
|
||||
}
|
||||
export interface GetSunPositionResult {
|
||||
altitude: number;
|
||||
azimuth: number;
|
||||
}
|
||||
export interface GetMoonPositionResult {
|
||||
altitude: number;
|
||||
azimuth: number;
|
||||
distance: number;
|
||||
parallacticAngle: number;
|
||||
}
|
||||
export interface GetMoonIlluminationResult {
|
||||
fraction: number;
|
||||
phase: number;
|
||||
angle: number;
|
||||
}
|
||||
export interface GetMoonTimes {
|
||||
rise: Date;
|
||||
set: Date;
|
||||
alwaysUp: boolean;
|
||||
alwaysDown: boolean;
|
||||
}
|
||||
|
||||
export function getTimes(date: Date, latitude: number, longitude: number): GetTimesResult;
|
||||
export function addTime(angleInDegrees: number, morningName: string, eveningName: string): void;
|
||||
export function getPosition(timeAndDate: Date, latitude: number, longitude: number): GetSunPositionResult;
|
||||
export function getMoonPosition(timeAndDate: Date, latitude: number, longitude: number): GetMoonPositionResult;
|
||||
export function getMoonIllumination(timeAndDate: Date): GetMoonIlluminationResult;
|
||||
export function getMoonTimes(date: Date, latitude: number, longitude: number, inUTC?: boolean): GetMoonTimes;
|
||||
48
types/suncalc/suncalc-tests.ts
Normal file
48
types/suncalc/suncalc-tests.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import * as SunCalc from 'suncalc';
|
||||
|
||||
let d: Date;
|
||||
let x: number;
|
||||
let b: boolean;
|
||||
|
||||
const date = new Date();
|
||||
const latitude = 0.0;
|
||||
const longitude = 0.0;
|
||||
|
||||
const times = SunCalc.getTimes(date, latitude, longitude);
|
||||
d = times.dawn;
|
||||
d = times.dusk;
|
||||
d = times.goldenHour;
|
||||
d = times.goldenHourEnd;
|
||||
d = times.nadir;
|
||||
d = times.nauticalDawn;
|
||||
d = times.nauticalDusk;
|
||||
d = times.night;
|
||||
d = times.nightEnd;
|
||||
d = times.solarNoon;
|
||||
d = times.sunrise;
|
||||
d = times.sunriseEnd;
|
||||
d = times.sunset;
|
||||
d = times.sunsetStart;
|
||||
|
||||
SunCalc.addTime(0.0, 'customTime', 'customTimeEnd');
|
||||
|
||||
const pos = SunCalc.getPosition(date, latitude, longitude);
|
||||
x = pos.altitude;
|
||||
x = pos.azimuth;
|
||||
|
||||
const mp = SunCalc.getMoonPosition(date, latitude, longitude);
|
||||
x = mp.altitude;
|
||||
x = mp.azimuth;
|
||||
x = mp.distance;
|
||||
x = mp.parallacticAngle;
|
||||
|
||||
const mi = SunCalc.getMoonIllumination(date);
|
||||
x = mi.fraction;
|
||||
x = mi.phase;
|
||||
x = mi.angle;
|
||||
|
||||
const mt = SunCalc.getMoonTimes(date, latitude, longitude, true);
|
||||
d = mt.rise;
|
||||
d = mt.set;
|
||||
b = mt.alwaysUp;
|
||||
b = mt.alwaysDown;
|
||||
22
types/suncalc/tsconfig.json
Normal file
22
types/suncalc/tsconfig.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"suncalc-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/suncalc/tslint.json
Normal file
1
types/suncalc/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user