This is the way I am adding all the events in to my calendar, those events are coming from table view. I have a problem with deleting a specific even from the calendar when the row on the table view gets deleted. The code that I am trying seems not to find and identifier in the calendar. Can you please let me know what I am missing here
ADD TO CALENDAR
let eventStore : EKEventStore = EKEventStore()
// 'EKEntityTypeReminder' or 'EKEntityTypeEvent'
eventStore.requestAccess(to: .event) { (granted, error) in
if (granted) && (error == nil) {
print("granted \(granted)")
print("error \(error)")
let event:EKEvent = EKEvent(eventStore: eventStore)
event.title = "Test Title"
event.startDate = Date()
event.endDate = Date()
event.notes = "This is a note"
event.calendar = eventStore.defaultCalendarForNewEvents
do {
try eventStore.save(event, span: .thisEvent)
} catch let error as NSError {
print("failed to save event with error : \(error)")
}
print("Saved Event")
}
else{
print("failed to save event with error : \(error) or access not granted")
}
}
DELETE FROM CALENDAR
func deleteEvent(_ storedEventID: String)
{
eventStore.requestAccess(to: .event, completion: { (granted, error) in
if (granted) && (error == nil)
{
if let calendarEvent_toDelete = self.eventStore.event(withIdentifier: storedEventID){
//recurring event
if calendarEvent_toDelete.recurrenceRules?.isEmpty == false
{
let alert = UIAlertController(title: "Repeating Event", message:
"This is a repeating event.", preferredStyle: UIAlertControllerStyle.alert)
//delete this event only
let thisEvent_Action = UIAlertAction(title: "Delete this event", style: UIAlertActionStyle.default)
{
(result : UIAlertAction) -> Void in
//sometimes doesn't delete anything, sometimes deletes all reccurent events, not just current!!!
do{
try self.eventStore.remove(calendarEvent_toDelete, span: .thisEvent)
} catch let e as NSError{return}
}
alert.addAction(thisEvent_Action)
}
//not recurring event
else{
//works fine
do{
try self.eventStore.remove(calendarEvent_toDelete, span: EKSpan.thisEvent)
} catch let e as NSError{
return
}
}
}
}
})
}
What I am missing in your example is to commit the changes to the event store.
Commit the changes immediately or with a separate commit while bulk processing multiple events.
try? self.eventStore.remove(eventToRemove, span: .thisEvent, commit: true)
Good luck and success.
first get the event using even Id then delete the event
func removeEvent(eventId: String, eventStore: EKEventStore) {
if let eventToDelete = self.eventStore.event(withIdentifier: eventId){
do {
try eventStore.remove(eventToDelete, span: .thisEvent)
} catch let error as NSError {
print("failed to save event with error : \(error)")
}
print("removed Event")
}
}
Related
I'm attempting to use ReplayKit and save the video of the screen capture to my camera roll.
However I'm getting an error when I try to save it at the very bottom of my code, that last error check: "Video did not save for some reason"
Optional(Error Domain=NSCocoaErrorDomain Code=-1 “(null)“)
“The operation couldn’t be completed. (Cocoa error -1.)”
I've looked around at a number of other questions similar to this but most of them have a trail of unanswered comments similar to "I'm getting this too, did you ever get an answer to this"
Would love some help on this. Thanks!
private func startRecording() {
//Create the file path to write to
let documentsPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] as NSString
self.videoOutputURL = URL(fileURLWithPath: documentsPath.appendingPathComponent(UUID.init().description + ".mp4"))
//Check the file does not already exist by deleting it if it does
do {
try FileManager.default.removeItem(at: videoOutputURL!)
} catch {}
do {
try videoWriter = AVAssetWriter(outputURL: videoOutputURL!, fileType: .mp4)
} catch let writerError as NSError {
print("Error opening video file", writerError);
videoWriter = nil;
return;
}
//Create the video settings
let videoSettings: [String : Any] = [
AVVideoCodecKey: AVVideoCodecType.h264,
AVVideoWidthKey: view.bounds.width,
AVVideoHeightKey: view.bounds.height
]
//Create the asset writer input object whihc is actually used to write out the video
//with the video settings we have created
videoWriterInput = AVAssetWriterInput(mediaType: .video, outputSettings: videoSettings);
videoWriterInput!.expectsMediaDataInRealTime = true
videoWriter?.add(videoWriterInput!);
let recorder = RPScreenRecorder.shared()
guard recorder.isAvailable else { return } // or throw error
recorder.startCapture(handler: { (buffer, sampleType, error) in
guard error == nil else {
return DispatchQueue.main.async { self.presentError(error!) }
}
switch sampleType {
case .video:
print("writing sample....")
switch self.videoWriter!.status {
case .unknown:
if self.videoWriter?.startWriting != nil {
print("Starting writing")
self.videoWriter!.startWriting()
self.videoWriter!.startSession(atSourceTime: CMSampleBufferGetPresentationTimeStamp(buffer))
}
case .writing:
if self.videoWriterInput!.isReadyForMoreMediaData {
print("Writing a sample")
if self.videoWriterInput!.append(buffer) == false {
print(" we have a problem writing video")
}
}
default: break
}
default:
print("not a video sample, so ignore");
}
})
}
private func stopRecording() {
let recorder = RPScreenRecorder.shared()
recorder.stopCapture { [unowned self] error in
guard error == nil else {
return DispatchQueue.main.async { self.presentError(error!) }
}
self.saveVideoToCameraRoll(completion: completion)
}
}
func saveVideoToCameraRoll(completion: (() -> Void)?) {
//Now save the video
PHPhotoLibrary.shared().performChanges({
print(self.videoOutputURL!)
PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: self.videoOutputURL!)
}) { saved, error in
if saved {
let alertController = UIAlertController(title: "Your video was successfully saved", message: nil, preferredStyle: .alert)
let defaultAction = UIAlertAction(title: "OK", style: .default) { _ in
completion?()
}
alertController.addAction(defaultAction)
self.present(alertController, animated: true, completion: nil)
}
if error != nil {
print("Video did not save for some reason", error.debugDescription)
debugPrint(error?.localizedDescription ?? "error is nil")
}
}
}
```
Seems like you forgot to finish writing to the file when you stop recording:
private func stopRecording() {
let recorder = RPScreenRecorder.shared()
recorder.stopCapture { [unowned self] error in
...
self.videoWriter?.finishWriting {
self.saveVideoToCameraRoll(completion: completion)
}
}
}
I'm trying to copy specific events from all calendars to the target calendar. Unfortunately my events are not saving in target calendar.
Simply my code in steps:
Check permissions (success)
Load calendars (success)
Load events (success)
Save events (failed)
I'm sure there are events to save from terminal which prints "Trying to save" couple of times.
And it looks like code pass through "try self.eventStore.save(event, span: .thisEvent)" and exits function there without calling "Saved" or entering catch clause.
There is a source code:
import UIKit
import EventKit
class ViewController: UIViewController{
#IBOutlet weak var status: UILabel!
var calendars: [EKCalendar]?
var targetCalendar: EKCalendar?
var targetCalendarEvents: [EKEvent]?
let eventStore = EKEventStore()
let targetCalendarName = "TargetCalendarName"
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func viewWillAppear(_ animated: Bool) {
DispatchQueue.main.async{
self.status.text = "Idle"
}
checkCalendarAuthorizationStatus()
}
func checkCalendarAuthorizationStatus() {
let status = EKEventStore.authorizationStatus(for: EKEntityType.event)
switch (status) {
case EKAuthorizationStatus.notDetermined:
// This happens on first-run
requestAccessToCalendar()
case EKAuthorizationStatus.authorized:
// Things are in line with being able to show the calendars in the table view
loadCalendars()
loadEvents()
case EKAuthorizationStatus.restricted, EKAuthorizationStatus.denied:
// We need to help them give us permission
print("Missing permissions [00]")
}
}
func requestAccessToCalendar() {
eventStore.requestAccess(to: EKEntityType.event, completion: {
(accessGranted: Bool, error: Error?) in
if accessGranted == true {
DispatchQueue.main.async(execute: {
self.loadCalendars()
self.loadEvents()
})
} else {
print("Missing permissions [01]")
}
})
}
func loadEvents(){
print("Loading..")
DispatchQueue.main.async{
self.status.text = "Loading"
}
let eventStore = EKEventStore()
var initialized = false
//Two months
let dateTo = NSDate(timeIntervalSinceNow: +30*24*3600 * 2)
for calendar in self.calendars! {
let predicate = eventStore.predicateForEvents(withStart: Date() as Date as Date, end: dateTo as Date, calendars: [calendar])
let events = eventStore.events(matching: predicate)
if calendar.title == targetCalendarName {
print("Initialized")
targetCalendar = calendar
targetCalendarEvents = events
initialized = true
}
}
if(!initialized){
print("Not Initialized")
} else {
for calendar in self.calendars! {
let predicate = eventStore.predicateForEvents(withStart: Date() as Date as Date, end: dateTo as Date, calendars: [calendar])
let events = eventStore.events(matching: predicate)
if calendar.title != targetCalendarName && calendar.title != "Contacts" {
//print("Loaded Calendar \(calendar.title)")
print("Loaded Calendar")
for event in events {
if(!(event.location?.isEmpty)!){
//print("Event \(event.location ?? "Missing Location") \(event.startDate) \(event.endDate)")
addEventToTarget(eventToAdd: event)
}
}
}
}
}
DispatchQueue.main.async {
self.status.text = "Done"
}
print("Done")
}
func loadCalendars() {
self.calendars = eventStore.calendars(for: EKEntityType.event)
}
func addEventToTarget(eventToAdd: EKEvent){
eventStore.requestAccess(to: .event) { (granted, error) in
for event in self.targetCalendarEvents! {
if(!(event.location?.isEmpty)!){
if(
eventToAdd.title == event.title &&
eventToAdd.startDate == event.startDate &&
eventToAdd.endDate == event.endDate
){
print("Possible duplicate - skipping")
return
}
}
}
if (granted) && (error == nil) {
let event:EKEvent = EKEvent(eventStore: self.eventStore)
event.title = eventToAdd.title
event.startDate = eventToAdd.startDate
event.endDate = eventToAdd.endDate
event.notes = ""
event.location = eventToAdd.location
event.calendar = self.targetCalendar
//print("Trying to save \(event.title) \(String(describing: event.location))")
print("Trying to save")
do {
try self.eventStore.save(event, span: .thisEvent)
print("Saved \(event.title) \(String(describing: event.location)) in \(event.calendar.title)")
} catch {
print("failed to save event with error : \(error as NSError)")
}
}
else{
print("failed to save event with error : \(String(describing: error)) or access not granted")
}
}
}
}
TargetCalendarName is correct calendar name
Sometimes there are events which saves successfully but only couple of them (2-5) for hundreds which should save. I don't have a clue why.
So 5 for 200 is not enough for me.
Thanks to #matt for proposing a solution.
Now I'm saving events ONCE (previously I was requesting access for every event which is very bad), so I request access to eventStore once and can save events succesfully.
func saveEvents(){
eventStore.requestAccess(to: .event) { (granted, error) in
if (granted) && (error == nil) {
for event in self.eventsToCopy {
print("Trying to save")
do {
try self.eventStore.save(event, span: .thisEvent)
print("Saved \(event.title) \(String(describing: event.location)) in \(event.calendar.title)")
} catch {
print("failed to save event with error : \(error as NSError)")
}
}
}
else{
print("failed to save event with error : \(String(describing: error)) or access not granted")
}
}
}
When restoring I get a crash fatal error: unexpectedly found nil while unwrapping an Optional value
Whenever I click the restore button to check if I had bought a package before, to test it out in sandbox. The function processTransactionRestore gets called to verify the receipt but the code is being executed multiple times around 20 every time. I have a print saying "Processing Transaction Restore" and in the logs you see the print 22 times and since I have a uialert to tell you that it failed. I get the uialert 22 times non stop.
Any help?
Subscription.swift
// When restore product
func processTransactionRestore(transaction: SKPaymentTransaction) {
if transaction.payment.productIdentifier == "com.example.year" {
print("Bought Year Package: Premium")
}
print("Processing Transaction Restore")
// Validate Receipt
Validation.validateReceipt( completed: {
if Validation.isSubscribed() {
DispatchQueue.main.async{
// Go To Protected Page: MainController
let mainPage = self.storyboard?.instantiateViewController(withIdentifier: "MainController") as! MainController
let mainPageNav = UINavigationController(rootViewController: mainPage)
let appDelegate = UIApplication.shared.delegate
appDelegate?.window??.rootViewController = mainPageNav
}
} else {
print("Not Validated! Nothing to restore.. Trying Again..")
// Alert
let alert = UIAlertController(title: "Nothing to Restore", message: "Unable to find any products to restore.", preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: "Dismiss", style: UIAlertActionStyle.default, handler: nil))
alert.addAction(UIAlertAction(title: "Try Again", style: UIAlertActionStyle.default, handler: { _ in
// Repeating Validate Receipt
Validation.validateReceipt( completed: {
if Validation.isSubscribed() {
DispatchQueue.main.async{
// Go To Protected Page: MainController
let mainPage = self.storyboard?.instantiateViewController(withIdentifier: "MainController") as! MainController
let mainPageNav = UINavigationController(rootViewController: mainPage)
let appDelegate = UIApplication.shared.delegate
appDelegate?.window??.rootViewController = mainPageNav
}
} else {
print("Not Validated! Nothing to process.. Trying Again..")
// Alert
let alert = UIAlertController(title: "Nothing to Process", message: "Unable to process any products.", preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: "Dismiss", style: UIAlertActionStyle.default, handler: nil))
alert.addAction(UIAlertAction(title: "Try Again", style: UIAlertActionStyle.default, handler: { _ in
print("Try Again button")
}))
self.present(alert, animated: true, completion: nil)
}
})
}))
self.present(alert, animated: true, completion: nil)
}
})
}
func paymentQueueRestoreCompletedTransactionsFinished(_ queue: SKPaymentQueue) {
print("Transactions Restored")
for transaction in queue.transactions {
processTransactionRestore(transaction: transaction)
}
}
Restore button
#IBAction func restoreButton(_ sender: Any) {
print("Restoring Purchase")
SKPaymentQueue.default().restoreCompletedTransactions()
}
Logs
Restoring Purchase
Transactions Restored
Bought Year Package: Premium
Processing Transaction Restore
Validating Receipt...
Processing Transaction Restore
Validating Receipt...
Processing Transaction Restore
Validating Receipt...
Bought Year Package: Premium
Processing Transaction Restore
Validating Receipt...
Processing Transaction Restore
Validating Receipt...
Bought Year Package: Premium
Processing Transaction Restore
Validating Receipt...
Bought Year Package: Premium
Processing Transaction Restore
Validating Receipt...
Processing Transaction Restore
Validating Receipt...
Bought Year Package: Premium
Not Validated! Nothing to restore.. Trying Again..
fatal error: unexpectedly found nil while unwrapping an Optional value
Validation.swift
public class Validation: UIViewController {
class func isSubscribed() -> Bool {
// Setting subscribed to be whatever its saved as
if let mainSubscribed: Bool = customKeychainWrapperInstance.bool(forKey: "isSubscribed") {
print("Found Key! for isSubscribed")
subscribed = mainSubscribed
} else {
print("No Key Found: Validating Receipt!")
subscribed = false
}
return subscribed
}
class func validateReceipt(completed:(() -> Void)?) {
var date_today_ms: Int64 = 0
var date_expires_ms: Int64 = 0
var statusCode: Int = 1
let receiptUrl = Bundle.main.appStoreReceiptURL
do {
print("Validating Receipt...")
// Run Activity Indicator
//
// Getting Data
let receipt: Data = try Data(contentsOf:receiptUrl!)
let receiptdata: NSString = receipt.base64EncodedString(options: NSData.Base64EncodingOptions(rawValue: 0)) as NSString
let request = NSMutableURLRequest(url: NSURL(string: "https://example.com/verify.php")! as URL)
let session = URLSession.shared
request.httpMethod = "POST"
request.httpBody = receiptdata.data(using: String.Encoding.ascii.rawValue)
let task = session.dataTask(with: request as URLRequest, completionHandler: {(data, response, error) in
do {
let json = try JSONSerialization.jsonObject(with: data!, options: .mutableContainers) as? NSDictionary
if(error != nil) {
print(error!.localizedDescription)
let jsonStr = NSString(data: data!, encoding: String.Encoding.utf8.rawValue)
print("Error could not parse JSON: '\(String(describing: jsonStr))'")
// isSubscribed is False
subscribed = false
saveSubscriptionKey()
} else {
if let parseJSON = json {
if (parseJSON["status"] as? Int == 0) {
print("Sucessfully returned purchased receipt data!")
statusCode = 0
// Checking "latest_receipt_info"
if let receiptInfo: NSArray = parseJSON["latest_receipt_info"] as? NSArray {
let lastReceipt = receiptInfo.lastObject as! NSDictionary
// Get last receipt
print("\nLast Receipt Information: \n", lastReceipt)
// Getting Expired Time in MS
if let expiresString = lastReceipt["expires_date_ms"] as? String, let expiresMS = Int64(expiresString) {
date_expires_ms = expiresMS / 1000
}
// Remember doing anything in the JSON causes failure
}
} else if (parseJSON["status"] as? Int == 21002) {
print("Status Code: 21002 - The data in the receipt-data property was malformed or missing.")
// try it again maybe 2 times then cancel it
// isSubscribed is False
subscribed = false
saveSubscriptionKey()
} else { // add more status codes statements
print("Status Code: Something went wrong!")
// cancel it
// isSubscribed is False
subscribed = false
saveSubscriptionKey()
}
} else {
let jsonStr = NSString(data: data!, encoding: String.Encoding.utf8.rawValue)
print("Receipt Error: \(String(describing: jsonStr))")
// isSubscribed is False
subscribed = false
saveSubscriptionKey()
}
}
} catch {
print("Error: (Receipt to JSON)")
// isSubscribed is False
subscribed = false
saveSubscriptionKey()
}
// ........ Outside the `do try JSON {` ....................
// is Validated [0]
if statusCode == 0 {
// [1] Checking 'Expired Date' //
print("date_expires: \(date_expires_ms)") // Date Expired
// Getting Todays Time in MS
date_today_ms = Int64(Date().timeIntervalSince1970) //* 1000
print("date_today: \(date_today_ms)")
if date_expires_ms < date_today_ms {
print("The product is EXPIRED!")
// isSubscribed is False
subscribed = false
saveSubscriptionKey()
} else {
print("The product is ACTIVE!")
// isSubscribed = True
subscribed = true
saveSubscriptionKey()
}
// [2] Checking Blank ...
}
if let completedBlock = completed {
completedBlock();
}
})
task.resume()
} catch {
print("Error: (Receipt URL)")
// isSubscribed is False
subscribed = false
saveSubscriptionKey()
if let completedBlock = completed {
completedBlock();
}
}
}
}
I am new to swift and i am practicing "Adding a Calendar Event" from this website: http://www.ioscreator.com/tutorials/add-event-calendar-tutorial-ios8-swift, but I am getting the following errors at line
let result = store.saveEvent(event, span: .ThisEvent, commit: error)
Call can throw, but it is not marked with 'try' and the error is not handled
Cannot convert value of type 'NSError?' to expected argument type 'Bool'
Code:
import UIKit
import EventKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let eventStore = EKEventStore()
switch EKEventStore.authorizationStatusForEntityType(EKEntityType.Event) {
case .Authorized:
insertEvent(eventStore)
case .Denied:
print("Access denied")
case .NotDetermined:
// 3
eventStore.requestAccessToEntityType(EKEntityType.Event, completion:
{[weak self] (granted: Bool, error: NSError?) -> Void in
if granted {
self!.insertEvent(eventStore)
} else {
print("Access denied")
}
})
default:
print("Case Default")
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func insertEvent(store : EKEventStore){
let calendars = store.calendarsForEntityType(EKEntityType.Event) as! [EKCalendar]
for calendar in calendars{
if calendar.title == "ioscreater"{
let startDate = NSDate()
let endDate = startDate.dateByAddingTimeInterval(2*60*60)
//Create event
var event = EKEvent(eventStore : store)
event.calendar = calendar
event.title = "New Meeting"
event.startDate = startDate
event.endDate = endDate
//Save event in Calendar
var error : NSError?
let result = store.saveEvent(event, span: .ThisEvent, commit: error)
if result == false{
if let theError = error{
print ("An error occured \(theError)")
}
}
}
}
}
}
I googled the errors but I could not find an appropriate solution.
This works for me in Swift 3.0
Firstly, You need to add "Privacy - Calendars Usage Description" in info.plist.
import EventKit
func addEventToCalendar(title: String, description: String?, startDate: Date, endDate: Date, completion: ((_ success: Bool, _ error: NSError?) -> Void)? = nil) {
let eventStore = EKEventStore()
eventStore.requestAccess(to: .event, completion: { (granted, error) in
if (granted) && (error == nil) {
let event = EKEvent(eventStore: eventStore)
event.title = title
event.startDate = startDate
event.endDate = endDate
event.notes = description
event.calendar = eventStore.defaultCalendarForNewEvents
do {
try eventStore.save(event, span: .thisEvent)
} catch let e as NSError {
completion?(false, e)
return
}
completion?(true, nil)
} else {
completion?(false, error as NSError?)
}
})
}
Then, you can easily call this method like the following:
addEventToCalendar(title: "Best friend birthday", description: "Remember you or miss you!", startDate: NSDate(), endDate: NSDate())
Thanks and enjoy coding!!!
func insertEvent(store : EKEventStore){
let calendars = store.calendarsForEntityType(EKEntityType.Event)
for calendar in calendars{
if calendar.title == "ioscreater"{
let startDate = NSDate()
let endDate = startDate.dateByAddingTimeInterval(2*60*60)
//Create event
var event = EKEvent(eventStore : store)
event.calendar = calendar
event.title = "New Meeting"
event.startDate = startDate
event.endDate = endDate
//Save event in Calendar
do {
try store.saveEvent(event, span: .ThisEvent)
} catch {
// Do error stuff here
}
}
Add saveEvent code in try,catch like below :
do {
try store.saveEvent(event, span: .ThisEvent)
} catch let err as NSError{
print ("An error occured \(err.description)")
}
The following code works, no problem at all.
let eventStore = EKEventStore()
eventStore.requestAccessToEntityType(.Event, completion: { (granted, error) in
if granted == false { return }
let e = EKEvent(eventStore: eventStore)
e.title = self.event!.title
let meh = self.event!.commencement
print("\(meh)")
e.startDate = meh
e.location = self.event!.venue.contact.address.assembleAddress()
let bleh = NSDate(timeInterval: Double(60*24*60*60), sinceDate: self.event!.commencement)
print("\(bleh)")
e.endDate = bleh
e.calendar = eventStore.defaultCalendarForNewEvents
e.URL = self.event!.marketingURL
e.addAlarm(EKAlarm(absoluteDate: self.event!.commencement.dateByAddingTimeInterval(Double(-60*60*24*7))))
do {
try eventStore.saveEvent(e, span: .ThisEvent, commit: true)
} catch let error as NSError {
print("error \(error)")
}
})
When I change the end date to 8 hours ahead of the commence date, the event is not created, or for a fleeting moment it is there, then the network activity indicator spins and it is removed.
let eventStore = EKEventStore()
eventStore.requestAccessToEntityType(.Event, completion: { (granted, error) in
if granted == false { return }
let e = EKEvent(eventStore: eventStore)
e.title = self.event!.title
let meh = self.event!.commencement
print("\(meh)")
e.startDate = meh
e.location = self.event!.venue.contact.address.assembleAddress()
let bleh = NSDate(timeInterval: Double(8*60*60), sinceDate: self.event!.commencement)
print("\(bleh)")
e.endDate = bleh
e.calendar = eventStore.defaultCalendarForNewEvents
e.URL = self.event!.marketingURL
e.addAlarm(EKAlarm(absoluteDate: self.event!.commencement.dateByAddingTimeInterval(Double(-60*60*24*7))))
do {
try eventStore.saveEvent(e, span: .ThisEvent, commit: true)
} catch let error as NSError {
print("error \(error)")
}
})
No error is printed. What's going on ?
The date is in the past. Make sure the date is in the future.