<commit_before>//
//  COTimePickerView.swift
//  countidon
//
//  Created by <NAME> on 13.10.16.
//  Derived from StackOverflow http://stackoverflow.com/questions/10999575/uipickerview-that-looks-like-uidatepicker-but-with-seconds ...
//  ... from the kind fella Mikael, http://stackoverflow.com/users/2015572/mikael
//  Copyright © 2016 Closure One. All rights reserved.
//

import UIKit

class COTimePickerView: UIPickerView, UIPickerViewDataSource, UIPickerViewDelegate {

    
    var hour:Int = 0
    var minute:Int = 0
  
  
  let pickerData = [
    Array(0...99),
    Array(0...59)
    ]
  
    required internal init?(coder aDecoder: NSCoder) {
      super.init(coder: aDecoder)
      self.setup()
    }
  
    override init(frame: CGRect) {
      super.init(frame: frame)
      self.setup()
    }
    
    func setup(){
      self.delegate = self
      self.dataSource = self
      
      /*let height = CGFloat(20)
       let offsetX = self.frame.size.width / 3
       let offsetY = self.frame.size.height/2 - height/2
       let marginX = CGFloat(42)
       let width = offsetX - marginX
       
       let hourLabel = UILabel(frame: CGRectMake(marginX, offsetY, width, height))
       hourLabel.text = "hour"
       self.addSubview(hourLabel)
       
       let minsLabel = UILabel(frame: CGRectMake(marginX + offsetX, offsetY, width, height))
       minsLabel.text = "min"
       self.addSubview(minsLabel)*/
    }
    
    func getDate() -> NSDate{
      let dateFormatter = DateFormatter()
      dateFormatter.dateFormat = "HH:mm"
      let date = dateFormatter.date(from: String(format: "%02d", self.hour) + ":" + String(format: "%02d", self.minute))
      return date! as NSDate
    }
    
    func numberOfComponents(in pickerView: UIPickerView) -> Int {
      return 2
    }
    
    func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
      switch component {
      case 0:
        self.hour = row
      case 1:
        self.minute = row
      default:
        print("No component with number \(component)")
      }
    }
    
    func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
      if component == 0 {
        return 24
      }
      
      return 60
    }
    
    func pickerView(_ pickerView: UIPickerView, rowHeightForComponent component: Int) -> CGFloat {
      return 30
    }
    
  // looks dangerous now
  func pickerView(_ pickerView: UIPickerView, viewForRow row: Int, forComponent component: Int, reusing view: UIView?) -> UIView {
      if (view != nil) {
        (view as! UILabel).text = String(format:"%02lu", row)
        return view!
      }
      let columnView = UILabel(frame: CGRect(x: 35, y: 0, width: self.frame.size.width/3 - 35, height: 30))
      columnView.text = String(format:"%02lu", row)
      columnView.textAlignment = NSTextAlignment.center
      
      return columnView
    }
    
}
<commit_msg>Working on time picker.<commit_after>//
//  COTimePickerView.swift
//  countidon
//
//  Created by <NAME> on 13.10.16.
//  Derived from StackOverflow http://stackoverflow.com/questions/10999575/uipickerview-that-looks-like-uidatepicker-but-with-seconds ...
//  ... from the kind fella Mikael, http://stackoverflow.com/users/2015572/mikael
//  Copyright © 2016 Closure One. All rights reserved.
//

import UIKit

class COTimePickerView: UIPickerView, UIPickerViewDataSource, UIPickerViewDelegate {

    // Only allowing hours so far.
    var hour:Int = 0
    var minute:Int = 0
  
  
  let pickerData = [
    Array(0...99),
    Array(0...59)
    ]
  
    required internal init?(coder aDecoder: NSCoder) {
      super.init(coder: aDecoder)
      self.setup()
    }
  
    override init(frame: CGRect) {
      super.init(frame: frame)
      self.setup()
    }
    
    func setup(){
      self.delegate = self
      self.dataSource = self
      
      /*let height = CGFloat(20)
       let offsetX = self.frame.size.width / 3
       let offsetY = self.frame.size.height/2 - height/2
       let marginX = CGFloat(42)
       let width = offsetX - marginX
       
       let hourLabel = UILabel(frame: CGRectMake(marginX, offsetY, width, height))
       hourLabel.text = "hour"
       self.addSubview(hourLabel)
       
       let minsLabel = UILabel(frame: CGRectMake(marginX + offsetX, offsetY, width, height))
       minsLabel.text = "min"
       self.addSubview(minsLabel)*/
    }
    
    func getDate() -> NSDate{
      let dateFormatter = DateFormatter()
      dateFormatter.dateFormat = "HH:mm"
      let date = dateFormatter.date(from: String(format: "%02d", self.hour) + ":" + String(format: "%02d", self.minute))
      return date! as NSDate
    }
    
    func numberOfComponents(in pickerView: UIPickerView) -> Int {
      return 2
    }
    
    func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
      switch component {
      case 0:
        self.hour = row
      case 1:
        self.minute = row
      default:
        print("No component with number \(component)")
      }
    }
    
    func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
      var returnValue = 0
      
      if component == 0 {
        returnValue = 24
      }
      
      if component == 1 {
        returnValue = 60
      }
      // only one exit rule
      return returnValue
    }
    
    func pickerView(_ pickerView: UIPickerView, rowHeightForComponent component: Int) -> CGFloat {
      return 30
    }
    
  // looks dangerous now
  func pickerView(_ pickerView: UIPickerView, viewForRow row: Int, forComponent component: Int, reusing view: UIView?) -> UIView {
      if (view != nil) {
        (view as! UILabel).text = String(format:"%02lu", row)
        return view!
      }
      let columnView = UILabel(frame: CGRect(x: 35, y: 0, width: self.frame.size.width/3 - 35, height: 30))
      columnView.text = String(format:"%02lu", row)
      columnView.textAlignment = NSTextAlignment.center
      
      return columnView
    }
    
}

{'fraction_non_alphanumeric': 0.11127596439169139, 'fraction_numerical': 0.022090339597757996, 'mean_word_length': 2.30987452264048, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5617368', 'n_tokens_mistral': 2038, 'n_tokens_neox': 1936, 'n_words': 474}