title: ListenerService Firebase not working with dates
body: <p>I've next model for my firebase entries for getting and fetching data:</p>
  <pre><code>struct MRecords: Hashable, Decodable {
  var text: String
  var date: Date
  var id: String
  
  init(text: String, date: Date, id: String) {
      self.text = text
      self.date = date
      self.id = id
  }
  
  init?(document: DocumentSnapshot) {
      guard let data = document.data() else { return nil}
      guard let text = data[&quot;text&quot;] as? String,
      let date = data[&quot;date&quot;] as? Date,
      let id = data[&quot;id&quot;] as? String
      
      else { return nil }
      
      self.text = text
      self.date = date
      self.id = id
  }
  
  init?(document: QueryDocumentSnapshot) {
      let data = document.data()
      guard let text = data[&quot;text&quot;] as? String,
      let date = data[&quot;date&quot;] as? Date,
      let id = data[&quot;id&quot;] as? String
      
      else { return nil }
      
      self.text = text
      self.date = date
      self.id = id
  }
  
  func hash(into hasher: inout Hasher) {
      hasher.combine(id)
  }
  
  static func == (lhs: MRecords, rhs: MRecords) -&gt; Bool {
      return lhs.id == rhs.id
  }
  
  func contains(filter: String?) -&gt; Bool {
      guard let filter = filter else { return true }
      if filter.isEmpty { return true }
      let lowercasedFilter = filter.lowercased()
      return text.lowercased().contains(lowercasedFilter)
  }
  </code></pre>
  <p>}</p>
  <p>And I'm using Listener to fetch data:</p>
  <pre><code> func recordsObserve(records: [MRecords], completion: @escaping (Result&lt;[MRecords], Error&gt;) -&gt; Void) -&gt; ListenerRegistration? {
          var records = records
          let recordsRef = db.collection([&quot;users&quot;, currentUserId, &quot;records&quot;].joined(separator: &quot;/&quot;))
          let recordsListener = recordsRef.addSnapshotListener { (querySnapshot, error) in
              guard let snapshot = querySnapshot else {
                  print(1)
                  completion(.failure(error!))
                  return
              }
              
              snapshot.documentChanges.forEach { (diff) in
                  guard let record = MRecords(document: diff.document) else { return }
                  switch diff.type {
                  case .added:
                      guard !records.contains(record) else { return }
                      records.append(record)
                  case .modified:
                      guard let index = records.firstIndex(of: record) else { return }
                      records[index] = record
                  case .removed:
                      guard let index = records.firstIndex(of: record) else { return }
                      records.remove(at: index)
                  }
              }
              
              completion(.success(records))
          }
          
          return recordsListener
      }
  </code></pre>
  <p>In my ViewController I'm using next code to get data into array:</p>
  <pre><code>waitingRecordsListener = ListenerService.shared.recordsObserve(records: records, completion: { (result) in
      switch result {
      case .success(let records):
          self.records = records
          self.tableView.reloadData()
      case .failure(let error):
          print(1)
      }
  })
  </code></pre>
  <p>}</p>
  <p>But it doesn't works! If I change in my model date property type from Date to String, it begin to work. How I can make it work with Date type, not only string?</p>