date-fns APIs
- format
- parseISO
- addDays
- subDays
- isAfter
- isBefore
- parse
- add
- startOfDay
- differenceInDays
- addHours
- addMinutes
- isSameDay
- formatDistance
- formatDistanceToNow
- endOfDay
- startOfWeek
- isEqual
- subHours
- getYear
- isToday
- startOfMonth
- differenceInMilliseconds
- addMonths
- eachDayOfInterval
- differenceInSeconds
- getDaysInMonth
- isValid
- endOfMonth
- startOfHour
- differenceInCalendarDays
- getUnixTime
- endOfWeek
- addWeeks
- sub
- toDate
- subMinutes
- fromUnixTime
- getDate
- getDay
- formatISO
- isWithinInterval
- subMonths
- subWeeks
- formatRelative
- differenceInMinutes
- differenceInHours
- getMonth
- getHours
- formatDistanceToNowStrict
- intervalToDuration
- addMilliseconds
- addYears
- endOfYear
- startOfMinute
- subYears
- isSameMonth
- formatDuration
- lightFormat
- setDate
- eachMonthOfInterval
- startOfYear
- isPast
- addSeconds
- isWeekend
- parseJSON
- set
- roundToNearestMinutes
- setMinutes
- differenceInCalendarYears
- max
- isTomorrow
- startOfToday
- isSameYear
- addQuarters
- endOfHour
- endOfQuarter
- startOfQuarter
- subSeconds
- getTime
- compareAsc
- differenceInWeeks
- eachWeekOfInterval
- eachYearOfInterval
- endOfYesterday
- setDay
- getDaysInYear
- formatISODuration
- getMilliseconds
- differenceInCalendarMonths
- lastDayOfMonth
- endOfDecade
- endOfMinute
- startOfDecade
- isThisISOWeek
- startOfTomorrow
- Duration
- startOfYesterday
- isYesterday
- setHours
- getMinutes
- compareDesc
- differenceInCalendarQuarters
- eachHourOfInterval
- eachQuarterOfInterval
- getISODay
- getWeek
- isDate
- isFriday
- isLeapYear
- isMonday
- isSameWeek
- isSaturday
- isSunday
- isThursday
- isTuesday
- isWednesday
- min
- setMonth
- Locale
- millisecondsInHour
- hoursToSeconds
Other Related APIs
- @angular/core#Injectable
- @angular/core#Inject
- @angular/core#Optional
- @angular/core#InjectionToken
- date-fns#format
- date-fns#toDate
- date-fns#parseJSON
- date-fns#parse
- date-fns#getMonth
- date-fns#getDate
- date-fns#getYear
- date-fns#getDaysInMonth
- date-fns#parseISO
- date-fns#getDay
- date-fns#addDays
- date-fns#addMonths
- date-fns#addYears
- date-fns#setMonth
- date-fns#Locale
- @angular/material/core#MAT_DATE_LOCALE
- @angular/material/core#DateAdapter
date-fns#setDay TypeScript Examples
The following examples show how to use
date-fns#setDay.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ngx-mat-datefns-date-adapter.ts From ngx-mat-datefns-date-adapter with MIT License | 6 votes |
getDayOfWeekNames(style: 'long' | 'short' | 'narrow'): string[] {
const map = {
long: 'EEEE',
short: 'EEE',
narrow: 'EEEEE',
};
const formatStr = map[style];
const date = new Date();
return range(0, 6).map((day) =>
format(setDay(date, day), formatStr, {
locale: this._dateFnsLocale,
})
);
}
Example #2
Source File: WeeklyCalendar.tsx From react-calendar with MIT License | 6 votes |
DayButton = ({ day }: DayButtonProps) => {
let { locale, week, selectedDay, changeSelectedDay } = useWeeklyCalendar();
let isSelected = selectedDay ? getDay(selectedDay) === day.day : false;
let currentDate = setDay(week, day.day, { locale });
return (
<li
onClick={() => changeSelectedDay(isSelected ? undefined : currentDate)}
className="rc-bg-white rc-cursor-pointer"
aria-label="Day of Week"
>
<div
className={`rc-rounded-lg rc-border sm:rc-w-36 rc-text-center rc-py-4 ${
isSelected
? 'rc-border-indigo-600'
: 'rc-border-gray-300 hover:rc-border-gray-500'
}`}
>
<p className="rc-font-medium rc-text-sm rc-text-gray-800">
{day.label} {format(currentDate, 'do', { locale })}
</p>
</div>
</li>
);
}