<commit_before>//
//  DurationDetailTableViewCell.swift
//  AlliCrab
//
//  Copyright © 2017 <NAME>. All rights reserved.
//

import UIKit

class DurationDetailTableViewCell: UITableViewCell {
    
    private static let durationFormatter: DateComponentsFormatter = {
        let formatter = DateComponentsFormatter()
        formatter.allowedUnits = [.day, .hour, .minute]
        formatter.allowsFractionalUnits = true
        formatter.collapsesLargestUnit = true
        formatter.maximumUnitCount = 2
        formatter.unitsStyle = .abbreviated
        formatter.zeroFormattingBehavior = .dropAll
        return formatter
    }()
    
    func update(text: String, duration: TimeInterval?) {
        textLabel!.text = text
        
        if let duration = duration {
            let formattedTimeSinceLevelStart = type(of: self).durationFormatter.string(from: duration, roundingUpwardToNearest: .oneMinute) ?? "???"
            detailTextLabel!.text = formattedTimeSinceLevelStart
            detailTextLabel!.textColor = .black
        } else {
            detailTextLabel!.text = "-"
            detailTextLabel!.textColor = .lightGray
        }
    }
    
}<commit_msg>Show zero or negative intervals as "Now"<commit_after>//
//  DurationDetailTableViewCell.swift
//  AlliCrab
//
//  Copyright © 2017 <NAME>. All rights reserved.
//

import UIKit

class DurationDetailTableViewCell: UITableViewCell {
    
    private static let durationFormatter: DateComponentsFormatter = {
        let formatter = DateComponentsFormatter()
        formatter.allowedUnits = [.day, .hour, .minute]
        formatter.allowsFractionalUnits = true
        formatter.collapsesLargestUnit = true
        formatter.maximumUnitCount = 2
        formatter.unitsStyle = .abbreviated
        formatter.zeroFormattingBehavior = .dropAll
        return formatter
    }()
    
    func update(text: String, duration: TimeInterval?) {
        textLabel!.text = text
        
        if let duration = duration {
            if duration <= 0 {
                detailTextLabel!.text = "Now"
            } else {
                let formattedTimeSinceLevelStart = type(of: self).durationFormatter.string(from: duration, roundingUpwardToNearest: .oneMinute) ?? "???"
                detailTextLabel!.text = formattedTimeSinceLevelStart
            }
            detailTextLabel!.textColor = .black
        } else {
            detailTextLabel!.text = "-"
            detailTextLabel!.textColor = .lightGray
        }
    }
    
}
{'fraction_non_alphanumeric': 0.08982035928143713, 'fraction_numerical': 0.004391217564870259, 'mean_word_length': 2.3413333333333335, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 5, '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': '2004403', 'n_tokens_mistral': 704, 'n_tokens_neox': 643, 'n_words': 142}