@prefecthq/prefect-ui-library
Version:
This library is the Vue and Typescript component library for [Prefect 2](https://github.com/PrefectHQ/prefect) and [Prefect Cloud 2](https://www.prefect.io/cloud/). _The components and utilities in this project are not meant to be used independently_.
18 lines (14 loc) • 502 B
text/typescript
import { MockFunction } from '@/services/Mocker'
import { DateString } from '@/types'
export const randomDate: MockFunction<Date, [Date?, Date?]> = function(start, end) {
if (!start) {
start = new Date(0)
}
if (!end) {
end = new Date()
}
return new Date(start.getTime() + Math.random() * (end.getTime() - start.getTime()))
}
export const randomDateString: MockFunction<DateString, [Date?, Date?]> = function(start, end) {
return this.create('date', [start, end]).toISOString()
}