Skip to content

Commit

Permalink
docs: add jsdoc to the conversion functions
Browse files Browse the repository at this point in the history
  • Loading branch information
pkuczynski committed Mar 23, 2022
1 parent 7a8c5dc commit 7d1c09d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/date.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import type { Faker } from '.';
import type { DateEntryDefinition } from './definitions';

/**
* Converts date passed as a string or Date to a Date object. If nothing passed, takes current date.
*
* @param date
*/
function toDate(date?: string | Date): Date {
if (date != null) {
return new Date(date instanceof Date ? date : Date.parse(date));
Expand All @@ -9,6 +14,11 @@ function toDate(date?: string | Date): Date {
return new Date();
}

/**
* Converts date passed as a string or Date to milliseconds. If nothing passed, takes current date.
*
* @param date
*/
function toMilliseconds(date?: string | Date): number {
if (date != null) {
return date instanceof Date ? date.getTime() : Date.parse(date);
Expand Down

0 comments on commit 7d1c09d

Please sign in to comment.