<commit_before>//
//  Date.swift
//  ProcessingKit
//
//  Created by AtsuyaSato on 2017/09/27.
//  Copyright © 2017年 <NAME>. All rights reserved.
//

import Foundation

protocol DateModelContract {
    func millis() -> Int
    func second() -> Int
    func minute() -> Int
    func hour() -> Int
    func day() -> Int
    func month() -> Int
    func year() -> Int
}

struct DateModel: DateModelContract {
    var currentDate: Date?
    // for test
    init(currentDate: Date) {
        self.currentDate = currentDate
    }

    init() {
    }

    func millis() -> Int {
        return self.getMillis()
    }

    func second() -> Int {
        return self.getComponents().second ?? 0
    }

    func minute() -> Int {
        return self.getComponents().minute ?? 0
    }

    func hour() -> Int {
        return self.getComponents().hour ?? 0
    }

    func day() -> Int {
        return self.getComponents().day ?? 0
    }

    func month() -> Int {
        return self.getComponents().month ?? 0
    }

    func year() -> Int {
        return self.getComponents().year ?? 0
    }

    private func getMillis() -> Int {
        let format = DateFormatter()
        format.dateFormat = "SSS"
        let millsStr = format.string(from: currentDate ?? Date())
        return Int(millsStr) ?? 0
    }

    private func getComponents() -> DateComponents {
        let calendar = Calendar.current
        let components = calendar.dateComponents([.year, .month, .day, .hour, .minute, .second], from: currentDate ?? Date())
        return components
    }
}

extension ProcessingView: DateModelContract {
    func millis() -> Int {
        return self.dateModel.millis()
    }

    func second() -> Int {
        return self.dateModel.second()
    }

    func minute() -> Int {
        return self.dateModel.minute()
    }

    func hour() -> Int {
        return self.dateModel.hour()
    }

    func day() -> Int {
        return self.dateModel.day()
    }

    func month() -> Int {
        return self.dateModel.month()
    }

    func year() -> Int {
        return self.dateModel.year()
    }
}
<commit_msg>:bug: Fix Date functions scope<commit_after>//
//  Date.swift
//  ProcessingKit
//
//  Created by AtsuyaSato on 2017/09/27.
//  Copyright © 2017年 <NAME>. All rights reserved.
//

import Foundation

protocol DateModelContract {
    func millis() -> Int
    func second() -> Int
    func minute() -> Int
    func hour() -> Int
    func day() -> Int
    func month() -> Int
    func year() -> Int
}

struct DateModel: DateModelContract {
    var currentDate: Date?
    // for test
    init(currentDate: Date) {
        self.currentDate = currentDate
    }

    init() {
    }

    func millis() -> Int {
        return self.getMillis()
    }

    func second() -> Int {
        return self.getComponents().second ?? 0
    }

    func minute() -> Int {
        return self.getComponents().minute ?? 0
    }

    func hour() -> Int {
        return self.getComponents().hour ?? 0
    }

    func day() -> Int {
        return self.getComponents().day ?? 0
    }

    func month() -> Int {
        return self.getComponents().month ?? 0
    }

    func year() -> Int {
        return self.getComponents().year ?? 0
    }

    private func getMillis() -> Int {
        let format = DateFormatter()
        format.dateFormat = "SSS"
        let millsStr = format.string(from: currentDate ?? Date())
        return Int(millsStr) ?? 0
    }

    private func getComponents() -> DateComponents {
        let calendar = Calendar.current
        let components = calendar.dateComponents([.year, .month, .day, .hour, .minute, .second], from: currentDate ?? Date())
        return components
    }
}

extension ProcessingView: DateModelContract {
    public func millis() -> Int {
        return self.dateModel.millis()
    }

    public func second() -> Int {
        return self.dateModel.second()
    }

    public func minute() -> Int {
        return self.dateModel.minute()
    }

    public func hour() -> Int {
        return self.dateModel.hour()
    }

    public func day() -> Int {
        return self.dateModel.day()
    }

    public func month() -> Int {
        return self.dateModel.month()
    }

    public func year() -> Int {
        return self.dateModel.year()
    }
}

{'fraction_non_alphanumeric': 0.1333955223880597, 'fraction_numerical': 0.008861940298507462, 'mean_word_length': 1.9579310344827585, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 51, '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': '3925918', 'n_tokens_mistral': 1307, 'n_tokens_neox': 1234, 'n_words': 349}