Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to type check a Date object in flow?

Tags:

I have a function that takes a Date object as its paramater. I am not able to figure out how to annotate this.

function diffDate (start: any, end:any) {  //....  }
How do I type annotate start and end as Date objects?
like image 977
Aakash Sigdel Avatar asked Oct 20 '16 02:10

Aakash Sigdel


People also ask

How do you check if it is a Date object?

If the variables are of Date object type, we will check whether the getTime() method for the date variable returns a number or not. The getTime() method returns the total number of milliseconds since 1, Jan 1970. If it doesn't return the number, it means the date is not valid.

How do you write a Date object?

You can create a Date object using the Date() constructor of java. util. Date constructor as shown in the following example. The object created using this constructor represents the current time.

What is the Date object?

JavaScript Date objects represent a single moment in time in a platform-independent format. Date objects contain a Number that represents milliseconds since 1 January 1970 UTC.


1 Answers

Thanks loganfsmyth and Nikita for the comments. It works as expected.

function diffDate (start: Date, end: Date) {     // ...  }
like image 184
Aakash Sigdel Avatar answered Sep 27 '22 21:09

Aakash Sigdel