Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a practical example using distantFuture?

DispatchTime and (NS)Date have the property distantFuture, which "returns a time in the distant future."

Discussion:

You can pass this value to methods that schedule work to have the system wait indefinitely for a particular event to occur or condition to be met.

I can't think of or find an example where I would actually need to use this. What is a good use case?

like image 324
mmd1080 Avatar asked Aug 27 '26 02:08

mmd1080


2 Answers

For example if you want to retrieve future events from a calendar with an unspecified end date.

In this case you can set the end date of the predicate to distantFuture.

like image 177
vadian Avatar answered Aug 28 '26 17:08

vadian


Here's an example what unspecific dates will be returned:

let date = Date()
// current, here: "Sep 30, 2020 at 9:27 AM"

let distantPast = Date.distantPast
// "Jan 1, 1 at 12:53 AM"

let distantFuture = Date.distantFuture
// "Jan 1, 4001 at 1:00 AM"
like image 39
SchmidtFx Avatar answered Aug 28 '26 17:08

SchmidtFx



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!