{"action":"created","issue":{"url":"https://api.github.com/repos/jessesquires/JSQMessagesViewController/issues/1392","labels_url":"https://api.github.com/repos/jessesquires/JSQMessagesViewController/issues/1392/labels{/name}","comments_url":"https://api.github.com/repos/jessesquires/JSQMessagesViewController/issues/1392/comments","events_url":"https://api.github.com/repos/jessesquires/JSQMessagesViewController/issues/1392/events","html_url":"https://github.com/jessesquires/JSQMessagesViewController/issues/1392","id":126685645,"number":1392,"title":"How can I show Date for all day same whatsapp not all 3 messages","user":{"login":"FadelSultan","id":12224396,"avatar_url":"https://avatars.githubusercontent.com/u/12224396?v=3","gravatar_id":"","url":"https://api.github.com/users/FadelSultan","html_url":"https://github.com/FadelSultan","followers_url":"https://api.github.com/users/FadelSultan/followers","following_url":"https://api.github.com/users/FadelSultan/following{/other_user}","gists_url":"https://api.github.com/users/FadelSultan/gists{/gist_id}","starred_url":"https://api.github.com/users/FadelSultan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FadelSultan/subscriptions","organizations_url":"https://api.github.com/users/FadelSultan/orgs","repos_url":"https://api.github.com/users/FadelSultan/repos","events_url":"https://api.github.com/users/FadelSultan/events{/privacy}","received_events_url":"https://api.github.com/users/FadelSultan/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/jessesquires/JSQMessagesViewController/labels/questions%20&%20help","name":"questions & help","color":"bfdadc"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-01-14T16:04:43Z","updated_at":"2016-01-14T16:26:04Z","closed_at":null,"body":"Hello \r\n\r\nFirst thank's for this project .\r\n\r\nI want this history for all day same app what sap  I don't want any change for history for the day !\r\n\r\n\r\n    var arrayDate = [String]()\r\n    \r\n    override func collectionView(collectionView: JSQMessagesCollectionView!, attributedTextForCellTopLabelAtIndexPath indexPath: NSIndexPath!) -> NSAttributedString! {\r\n        let message = messages[indexPath.item]\r\n        \r\n        let dateFormatter = NSDateFormatter()\r\n        dateFormatter.dateFormat = \"yyyy-MM-dd\" // superset of OP's format\r\n        \r\n        let DateDataBase = dateFormatter.stringFromDate(message.date)\r\n        //        let date = dateFormatter.dateFromString(DateDataBase)\r\n        \r\n        print(\"\\(DateDataBase)\")\r\n        if (!arrayDate.contains(DateDataBase))\r\n        {\r\n            print(\"count : \\(arrayDate.count)\")\r\n            print(\"After : \\(arrayDate.contains(DateDataBase))\")\r\n            arrayDate.append(DateDataBase)\r\n            return JSQMessagesTimestampFormatter.sharedFormatter().attributedTimestampForDate(message.date)\r\n        }\r\n        return nil\r\n        \r\n    }\r\n    \r\n    var arrayDate1 = [String]()\r\n    override func collectionView(collectionView: JSQMessagesCollectionView!, layout collectionViewLayout: JSQMessagesCollectionViewFlowLayout!, heightForCellTopLabelAtIndexPath indexPath: NSIndexPath!) -> CGFloat {\r\n        let message = messages[indexPath.item]\r\n        \r\n        \r\n        let dateFormatter = NSDateFormatter()\r\n        dateFormatter.dateFormat = \"yyyy-MM-dd\" // superset of OP's format\r\n        \r\n        let DateDataBase = dateFormatter.stringFromDate(message.date)\r\n        print(\"\\(DateDataBase)\")\r\n        print(\"message.date \\(message.date)\")\r\n        if (!arrayDate1.contains(DateDataBase) )\r\n        {\r\n            \r\n            print(\"After : \\(arrayDate1.contains(DateDataBase))\")\r\n            arrayDate1.append(DateDataBase)\r\n            return kJSQMessagesCollectionViewCellLabelHeightDefault\r\n            \r\n        }\r\n        return 0.0\r\n    }"},"comment":{"url":"https://api.github.com/repos/jessesquires/JSQMessagesViewController/issues/comments/171690096","html_url":"https://github.com/jessesquires/JSQMessagesViewController/issues/1392#issuecomment-171690096","issue_url":"https://api.github.com/repos/jessesquires/JSQMessagesViewController/issues/1392","id":171690096,"user":{"login":"MurLuck","id":11195289,"avatar_url":"https://avatars.githubusercontent.com/u/11195289?v=3","gravatar_id":"","url":"https://api.github.com/users/MurLuck","html_url":"https://github.com/MurLuck","followers_url":"https://api.github.com/users/MurLuck/followers","following_url":"https://api.github.com/users/MurLuck/following{/other_user}","gists_url":"https://api.github.com/users/MurLuck/gists{/gist_id}","starred_url":"https://api.github.com/users/MurLuck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MurLuck/subscriptions","organizations_url":"https://api.github.com/users/MurLuck/orgs","repos_url":"https://api.github.com/users/MurLuck/repos","events_url":"https://api.github.com/users/MurLuck/events{/privacy}","received_events_url":"https://api.github.com/users/MurLuck/received_events","type":"User","site_admin":false},"created_at":"2016-01-14T16:26:03Z","updated_at":"2016-01-14T16:26:03Z","body":"//-------------------------------------------------------------------------------------------------------------------------------------------------\r\n    override func collectionView(collectionView: JSQMessagesCollectionView!, layout collectionViewLayout: JSQMessagesCollectionViewFlowLayout!, heightForCellTopLabelAtIndexPath indexPath: NSIndexPath!) -> CGFloat {\r\n//-------------------------------------------------------------------------------------------------------------------------------------------------\r\n        let msg = self.messages[indexPath.item]\r\n        var preMsg:TVChatMessageTemplate?\r\n        if indexPath.item != 0{\r\n            preMsg = self.messages[indexPath.item - 1]\r\n        }\r\n\r\n        \r\n        if indexPath.item == 0{\r\n            return kJSQMessagesCollectionViewCellLabelHeightDefault\r\n        }else if indexPath.item - 1 > 0 && preMsg!.date.date != msg.date.date {\r\n            let premsg = self.messages[indexPath.item - 1]\r\n            let msg = self.messages[indexPath.item]\r\n            if msg.date.timeIntervalSinceDate(premsg.date)/60 > 1{\r\n                return kJSQMessagesCollectionViewCellLabelHeightDefault\r\n            }\r\n        }\r\n        \r\n        return 0.0\r\n    }\r\n\r\n//-------------------------------------------------------------------------------------------------------------------------------------------------\r\n    override func collectionView(collectionView: JSQMessagesCollectionView!, attributedTextForCellTopLabelAtIndexPath indexPath: NSIndexPath!) -> NSAttributedString! {\r\n//-------------------------------------------------------------------------------------------------------------------------------------------------\r\n        let msg = self.messages[indexPath.item]\r\n        var preMsg:TVChatMessageTemplate?\r\n        if indexPath.item != 0{\r\n            preMsg = self.messages[indexPath.item - 1]\r\n        }\r\n    \r\n        if indexPath.item == 0{\r\n            let date = JSQMessagesTimestampFormatter.sharedFormatter().relativeDateForDate(msg.date)\r\n            return NSAttributedString(string: date)\r\n        }else if indexPath.item - 1 > 0 && preMsg!.date.date != msg.date.date{\r\n            let date = JSQMessagesTimestampFormatter.sharedFormatter().relativeDateForDate(msg.date)\r\n            return NSAttributedString(string: date)\r\n        }\r\n        return nil\r\n    }\r\n"}}