Skip to content

Instantly share code, notes, and snippets.

@jameskraus
Created May 12, 2017 20:44
Show Gist options
  • Save jameskraus/5dc0fa9b13398b78d296f9855593c9b4 to your computer and use it in GitHub Desktop.
Save jameskraus/5dc0fa9b13398b78d296f9855593c9b4 to your computer and use it in GitHub Desktop.
Override default flow definition
// @flow
declare class Date {
constructor(): void;
constructor(timestamp: number): void;
constructor(dateString: string): void;
constructor(year: number, month: number, day?: number, hour?: number, minute?: number, second?: number, millisecond?: number): void;
getDate(): number;
getDay(): number;
getYear(): number;
getFullYear(): number;
getHours(): number;
getMilliseconds(): number;
getMinutes(): number;
getMonth(): number;
getSeconds(): number;
getTime(): number;
getTimezoneOffset(): number;
getUTCDate(): number;
getUTCDay(): number;
getUTCFullYear(): number;
getUTCHours(): number;
getUTCMilliseconds(): number;
getUTCMinutes(): number;
getUTCMonth(): number;
getUTCSeconds(): number;
setDate(date: number): number;
setFullYear(year: number, month?: number, date?: number): number;
setHours(hours: number, min?: number, sec?: number, ms?: number): number;
setMilliseconds(ms: number): number;
setMinutes(min: number, sec?: number, ms?: number): number;
setMonth(month: number, date?: number): number;
setSeconds(sec: number, ms?: number): number;
setTime(time: number): number;
setUTCDate(date: number): number;
setUTCFullYear(year: number, month?: number, date?: number): number;
setUTCHours(hours: number, min?: number, sec?: number, ms?: number): number;
setUTCMilliseconds(ms: number): number;
setUTCMinutes(min: number, sec?: number, ms?: number): number;
setUTCMonth(month: number, date?: number): number;
setUTCSeconds(sec: number, ms?: number): number;
toDateString(): string;
toISOString(): string;
toJSON(key?: any): string;
toLocaleDateString(locales?: string, options?: Date$LocaleOptions): string;
toLocaleString(locales?: string, options?: Date$LocaleOptions): string;
toLocaleTimeString(locales?: string, options?: Date$LocaleOptions): string;
toTimeString(): string;
toUTCString(): string;
valueOf(): number;
static ():string;
static now(): number;
static parse(s: string): number;
static UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number;
// multiple indexers not yet supported
[key: $SymbolToPrimitive]: (hint: 'string' | 'default' | 'number') => string | number;
}
const myDate = new Date();
const shortYear = myDate.getYear();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment