title: Animating date changes in SwiftUI
body: <p>I am struggling to create an animation of a changing date value. A simplified example is below. It is intended to update the Text view with changing values as the date is updated from its original value to its new value. Help would be most appreciated!</p>
  <pre><code>struct DateAnimationView: View {
  
      @State var date = Date()
  
      typealias AnimatableData = Date
  
      var animatableData: Date{
          get{date}
          set{date = newValue}
      }
  
      var body: some View {
          VStack{
              Text(date, style: .time)
                  .padding()
              
              Button(action:{
                  withAnimation(.linear(duration: 3.0)){
                      date.addTimeInterval(60 * 60 * 3)
                  }
              }){
                  Text(&quot;Add 3 hours&quot;)
              }
                  .padding()
              Spacer()
          }
      }
  }
  </code></pre>
  <p>Another attempt which also fails:</p>
  <pre><code>struct InnerView: View {
      var date: Date
      var interval: TimeInterval
          
      typealias AnimatableData = TimeInterval
      
      var animatableData: TimeInterval{
          get{interval}
          set{interval = newValue}
      }
      
      var body: some View{
          Text(date.addingTimeInterval(interval), style: .time)
      }
  }
  
  struct DateAnimationView: View{
      @State var isOn: Bool = false
      var body: some View{
          VStack{
              InnerView(date: Date(), interval: isOn ? 60*60*3 : 0)
              Button(action:{
                  isOn.toggle()
              }){
                  Text(&quot;Go&quot;)
              }
          }
      }
  }
  </code></pre>