 
 // MARK: - Animations
 
-private extension GCCalendarDayView {
-    
-    func animateSelection() {
-        
-        self.animateToScale(0.9) { finished in self.animateToScale(1.1) { finished in self.animateToScale(1.0) } }
-    }
-    
-    func animateToScale(_ scale: CGFloat, completion: ((Bool) -> Void)? = nil) {
+fileprivate extension GCCalendarDayView {
+    
+    fileprivate func animateSelection() {
+        
+        self.animate(toScale: 0.9) { finished in
+            
+            if finished {
+                
+                self.animate(toScale: 1.1) { finished in
+                    
+                    if finished {
+                        
+                        self.animate(toScale: 1.0)
+                    }
+                }
+            }
+        }
+    }
+    
+    fileprivate func animate(toScale scale: CGFloat, completion: ((Bool) -> Void)? = nil) {
         
         UIView.animate(withDuration: 0.1, animations: {
             

        
        super.init(frame: CGRect.zero)
        
        self.addButton()
        self.addTapGestureRecognizer()
    }
}

// MARK: - Button

private extension GCCalendarDayView {
    
    // MARK: Creation
    
    func addButton() {
        
        self.button.layer.cornerRadius = self.buttonWidth / 2
        self.button.translatesAutoresizingMaskIntoConstraints = false
        
        self.button.addTarget(self, action: #selector(self.highlight), for: .touchUpInside)
        
        self.addSubview(self.button)
        self.addButtonConstraints()
    }
    
    func formatButton() {
        
        self.button.titleLabel!.font = self.font
        self.button.setTitleColor(self.textColor, for: .normal)
    }
    
    // MARK: Constraints
    
    func addButtonConstraints() {
        
        let width = NSLayoutConstraint(item: self.button, attribute: .width, relatedBy: .equal, toItem: nil, attribute: .width, multiplier: 1, constant: self.buttonWidth)
        let height = NSLayoutConstraint(item: self.button, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .height, multiplier: 1, constant: self.buttonWidth)
        let centerX = NSLayoutConstraint(item: self.button, attribute: .centerX, relatedBy: .equal, toItem: self, attribute: .centerX, multiplier: 1, constant: 0)
        let centerY = NSLayoutConstraint(item: self.button, attribute: .centerY, relatedBy: .equal, toItem: self, attribute: .centerY, multiplier: 1, constant: 0)
        
        self.addConstraints([width, height, centerX, centerY])
    }
}

// MARK: - Tap Gesture Recognizer

fileprivate extension GCCalendarDayView {
    
    fileprivate func addTapGestureRecognizer() {
        
        self.tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(self.highlight))
        
        self.addGestureRecognizer(self.tapGestureRecognizer)
    }
}



import UIKit

fileprivate enum GCCalendarDateType {
    
    case past, current, future, none
}
