From c106de1b548682475c1f044ec84bbeca016dbcc5 Mon Sep 17 00:00:00 2001 From: Feliciaan De Palmenaer Date: Thu, 26 Nov 2015 15:05:58 +0100 Subject: [PATCH] If date is today, use today instead of todays date v2 --- iOS/Hydra/HomeActivityCollectionViewCell.swift | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/iOS/Hydra/HomeActivityCollectionViewCell.swift b/iOS/Hydra/HomeActivityCollectionViewCell.swift index faf00954..eb1a5940 100644 --- a/iOS/Hydra/HomeActivityCollectionViewCell.swift +++ b/iOS/Hydra/HomeActivityCollectionViewCell.swift @@ -26,7 +26,19 @@ class HomeActivityCollectionViewCell: UICollectionViewCell { titleLabel.text = activity?.title dateEndFormatter.dateFormat = "H:mm"; - if (self.activity!.end != nil) { + if (self.activity!.start.isToday()) { + if self.activity!.start.dateByAddingDays(1).isLaterThanDate(self.activity!.end) { + dateLabel.text = "vandaag \(dateEndFormatter.stringFromDate((self.activity?.start)!)) - \(dateEndFormatter.stringFromDate((self.activity?.end)!))" + } else { + dateLabel.text = "vandaag \(dateEndFormatter.stringFromDate((self.activity?.start)!)) - \(dateStartFormatter.stringFromDate((self.activity?.end)!))" + } + } else if (self.activity!.start.isTomorrow()) { + if self.activity!.start.dateByAddingDays(1).isLaterThanDate(self.activity!.end) { + dateLabel.text = "morgen \(dateEndFormatter.stringFromDate((self.activity?.start)!)) - \(dateEndFormatter.stringFromDate((self.activity?.end)!))" + } else { + dateLabel.text = "morgen \(dateEndFormatter.stringFromDate((self.activity?.start)!)) - \(dateStartFormatter.stringFromDate((self.activity?.end)!))" + } + } else if (self.activity!.end != nil) { if self.activity!.start.dateByAddingDays(1).isLaterThanDate(self.activity!.end) { dateLabel.text = "\(dateStartFormatter.stringFromDate((self.activity?.start)!)) - \(dateEndFormatter.stringFromDate((self.activity?.end)!))" } else {