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
date-fns#min TypeScript Examples
The following examples show how to use
date-fns#min.
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: make-long-term-log.ts From merged-pr-stat with MIT License | 5 votes |
async function main(): Promise<void> {
program.requiredOption("--start <date>").requiredOption("--end <date>").requiredOption("--query <query>");
program.parse(process.argv);
const startDate = parseISO(program.start);
const endDate = parseISO(program.end);
const query = program.query as string;
const intervalDays = 7;
const allLogs = [];
process.stdout.write(
"title,author,url,createdAt,mergedAt,additions,deletions,authoredDate,leadTimeSeconds,timeToMergeSeconds\n"
);
for (let start = startDate; start < endDate; start = addDays(start, intervalDays)) {
const end = min([add(start, { days: intervalDays, seconds: -1 }), endDate]);
console.error(format(start, "yyyy-MM-dd HH:mm:ss"));
console.error(format(end, "yyyy-MM-dd HH:mm:ss"));
const stdout = execFileSync(
"merged-pr-stat",
["log", "--start", start.toISOString(), "--end", end.toISOString(), "--query", query],
{ encoding: "utf8" }
);
const logs: any[] = JSON.parse(stdout);
process.stdout.write(
csvStringify(
logs.map((l) => [
l.title,
l.author,
l.url,
l.createdAt,
l.mergedAt,
l.additions,
l.deletions,
l.authoredDate,
l.leadTimeSeconds,
l.timeToMergeSeconds,
])
)
);
}
}