@mikezimm/npmfunctions
Version:
Functions used in my SPFx webparts
42 lines (41 loc) • 1.73 kB
TypeScript
/**
* This was built for TrackMyTime and will get the Sunday or Monday of the week of 'd'.
* It returns the prior Sunday or prior Monday.
*
* Similarly getOffSetDayOfWeek can do this but it can uses different calculation
*
* Based upon: https://stackoverflow.com/questions/4156434/javascript-get-the-first-day-of-the-week-from-current-date
*
* @param d
* @param sunOrMon
*/
export declare function getDayOfWeek(d: any, sunOrMon: string): Date;
export declare function ISO8601_week_no(dt: any): number;
/**
* Created for GridCharts
* @param theDate
*/
export declare function getYearWeekLabel(theDate: Date): any;
/**
* This is similar to getDayOfWeek except more complex:
*
* Function does not adjust the timestamp.
* So if the day number is the same even if it's earlier or later, it will return the date you originally passed in.
*
* You can pass in any day number (0 for Sunday) and which = prior or next.
* 0 = Sunday, 1 = Monday, 2 = Tuesday, 3 = Wednesday, 4 = Thursday, 5 = Friday, 6 = Saturday
*
* Which = prior:
* Say today is Wednesday and you request day 2, that would return Tuesday (yesterday)
* say today is Wednesday and you request day 4, that would return LAST Thursday because that is the first prior Thursday.
*
* Which = next:
* Say today is Wednesday and you request day 2, that will return NEXT Tuesday
* Say today is Wednesday and you request day 4, that will return tommorrow.
*
* Pass in a date, the day number to get and wether it's prior or future and it will get the date.
* @param d
* @param day
* @param which
*/
export declare function getOffSetDayOfWeek(d: string, day: number, which: 'prior' | 'next'): Date;