I want to check how many seconds passed since one timestamp to now. I have this:
Calendar.current.dateComponents([.second], from: userInfo?["timestamp"], to: Date()).second! > preferences["secsToWait"]
But I'm getting this error:
Type 'Any' has no member 'second'
Changing the code to this:
Calendar.current.dateComponents([Calendar.Component.second], from: userInfo?["timestamp"], to: Date()).second! > preferences["secsToWait"]
changes the error message to:
Cannot invoke 'dateComponents' with an argument list of type '([Calendar.Component], from: Any?, to: Date)'
I do have this on top:
import Foundation;
This code is called inside SafariExtensionHandler
(if it matters). Any idea of what's causing it?