<commit_before>
import Foundation

public extension Date {
    
    public func toDateString() -> String {
        return format(.Date)
    }
    
    public func toDateTimeString() -> String {
        return format(.DateTime)
    }
    
    public func format(_ dateFormat: DateFormatter.Format = .DateTime) -> String {
        return DateFormatter().format(dateFormat: dateFormat.rawValue).string(from: self)
    }
    
    public init(dateString: String, _ format: DateFormatter.Format = .DateTime) {
        
        let dateFormatter = DateFormatter().format(dateFormat: format.rawValue)
        guard let date = dateFormatter.date(from: dateString) else {
            self = Date()
            return
        }
        self = date
    }
}

public extension String {

    public func toDate() -> Date? {
        return format(.Date)
    }
    
    public func toDateTime() -> Date? {
        return format(.DateTime)
    }
    
    func format(_ dateFormat: DateFormatter.Format = .DateTime) -> Date? {
        return DateFormatter().format(dateFormat: dateFormat.rawValue).date(from: self) as Date?
    }
    
    func urlSafeBase64() -> String {
        var base64 = self
        base64 = base64.replacingOccurrences(of: "+", with: "_")
        base64 = base64.replacingOccurrences(of: "/", with: "_")
        return base64
    }
    
}

public extension DateFormatter {<commit_msg>修复偶尔出现 bad token<commit_after>
import Foundation

public extension Date {
    
    public func toDateString() -> String {
        return format(.Date)
    }
    
    public func toDateTimeString() -> String {
        return format(.DateTime)
    }
    
    public func format(_ dateFormat: DateFormatter.Format = .DateTime) -> String {
        return DateFormatter().format(dateFormat: dateFormat.rawValue).string(from: self)
    }
    
    public init(dateString: String, _ format: DateFormatter.Format = .DateTime) {
        
        let dateFormatter = DateFormatter().format(dateFormat: format.rawValue)
        guard let date = dateFormatter.date(from: dateString) else {
            self = Date()
            return
        }
        self = date
    }
}

public extension String {

    public func toDate() -> Date? {
        return format(.Date)
    }
    
    public func toDateTime() -> Date? {
        return format(.DateTime)
    }
    
    func format(_ dateFormat: DateFormatter.Format = .DateTime) -> Date? {
        return DateFormatter().format(dateFormat: dateFormat.rawValue).date(from: self) as Date?
    }
    
    func urlSafeBase64() -> String {
        return self.replacingOccurrences(of: "+", with: "-").replacingOccurrences(of: "/", with: "_")
    }
    
}

public extension DateFormatter {
{'fraction_non_alphanumeric': 0.11016635859519408, 'fraction_numerical': 0.005914972273567467, 'mean_word_length': 2.3407407407407406, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '7313222', 'n_tokens_mistral': 773, 'n_tokens_neox': 748, 'n_words': 184}