<commit_before>//
//  RedditModel.swift
//  Reddit-App
//
//  Created by <NAME> on 11/2/17.
//  Copyright © 2017 Busico. All rights reserved.
//

import Foundation

struct RedditModel {

  let name: String
  let title: String
  let author: String
  let commentsCount: Int
  let dateCreated: Date
  let thumbnailURL: URL?
  let imageURL: URL?

  init(name: String,
    title: String,
    author: String,
    commentsCount: Int,
    dateCreated: Date,
    thumbnailURL: URL?,
    imageURL: URL?) {

    self.name = name
    self.title = title
    self.author = author
    self.commentsCount = commentsCount
    self.dateCreated = dateCreated
    self.thumbnailURL = thumbnailURL
    self.imageURL = imageURL
  }
}<commit_msg>Implementing formatter for time since submission.<commit_after>//
//  RedditModel.swift
//  Reddit-App
//
//  Created by <NAME> on 11/2/17.
//  Copyright © 2017 Busico. All rights reserved.
//

import Foundation

struct RedditModel {

  let name: String
  let title: String
  let author: String
  let commentsCount: Int
  let dateCreated: Date
  let thumbnailURL: URL?
  let imageURL: URL?

  init(name: String,
    title: String,
    author: String,
    commentsCount: Int,
    dateCreated: Date,
    thumbnailURL: URL?,
    imageURL: URL?) {

    self.name = name
    self.title = title
    self.author = author
    self.commentsCount = commentsCount
    self.dateCreated = dateCreated
    self.thumbnailURL = thumbnailURL
    self.imageURL = imageURL
  }

  func formattedTimeSinceSubmissions() -> String {
    let currentDate = Date()
    let timeInterval = currentDate.timeIntervalSince(dateCreated)

    if timeInterval < 60 {
      return "just now"
    }

    let minutes = Int(timeInterval / 60)
    if minutes < 60 {
      if minutes == 1 {
        return "a minute ago"
      } else {
        return "\(minutes) minutes ago"
      }
    }

    let hours = Int(minutes / 60)
    if hours < 24 {
      if hours == 1 {
        return "an hour ago"
      } else {
        return "\(hours) hours ago"
      }
    }
    
    let days = Int(hours / 24)
    if days == 1 {
      return "a day ago"
    } else {
      return "\(days) days ago"
    }
  }
}
{'fraction_non_alphanumeric': 0.1, 'fraction_numerical': 0.015137614678899083, 'mean_word_length': 2.3246951219512195, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 6, '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': '5904511', 'n_tokens_mistral': 721, 'n_tokens_neox': 677, 'n_words': 210}