     func isInPeriod(_ time: Int64) -> Bool {
         return time >= start!.int64Value && !isFinished(time)
     }
-}
+    
+    override init() {
+        super.init()
+    }
+    
+    required init(instance: Session) {
+        self.start = instance.start
+        self.duration = instance.duration
+        self.end = instance.end
+        self.cycle = instance.cycle
+    }
+}

    func isFinished(_ time: Int64) -> Bool {
        var e: Int64!
        if cycle == 0 && end == 0 {
            e = start + duration
        } else if end == 0 {
            e = Int64.max
        } else {
            e = end
        }

        return time >= e

                        exRemaining += exception.remaining(time + exRemaining)
                    }
                }
                if findCurrentSession(time: time + exRemaining) != nil {
                    return exRemaining
                }
            }
