Skip to content

Commit

Permalink
Merge branch 'pr/162' into swift
Browse files Browse the repository at this point in the history
# Conflicts:
#	DateTools/Date+TimeAgo.swift
  • Loading branch information
Matthew York committed Sep 21, 2016
2 parents 3baa87c + d2b072e commit 36ee1de
Show file tree
Hide file tree
Showing 15 changed files with 35 additions and 41 deletions.
6 changes: 3 additions & 3 deletions DateTools.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'DateTools'
s.version = '1.7.0'
s.version = '2.0.0-beta.1'
s.summary = 'Dates and time made easy in Objective-C'
s.homepage = 'https://github.com/MatthewYork/DateTools'

Expand All @@ -12,8 +12,8 @@ Pod::Spec.new do |s|
s.source = { :git => "https://github.com/MatthewYork/DateTools.git",
:tag => "v#{s.version.to_s}" }

s.ios.platform = :ios, '7.0'
s.osx.platform = :iox, '10.7'
s.ios.deployment_target = '7.0'
s.osx.deployment_target = '10.7'
s.requires_arc = true

s.source_files = 'DateTools'
Expand Down
2 changes: 1 addition & 1 deletion DateTools/Date+Comparators.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import Foundation

extension Date {
public extension Date {

// MARK: - Addition / Subtractions

Expand Down
2 changes: 1 addition & 1 deletion DateTools/Date+Components.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import Foundation

extension Date {
public extension Date {
func component(_ component: Calendar.Component, from date: Date) -> Int {
let calendar = Calendar.autoupdatingCurrent
return calendar.component(component, from: date)
Expand Down
2 changes: 1 addition & 1 deletion DateTools/Date+DateTools.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Foundation

*/

extension Date {
public extension Date {

// MARK: - Initializers

Expand Down
2 changes: 1 addition & 1 deletion DateTools/Date+Format.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import Foundation

extension Date {
public extension Date {

// MARK: - Formatted Date - Style

Expand Down
18 changes: 6 additions & 12 deletions DateTools/Date+TimeAgo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import Foundation

extension Date {
public extension Date {


//MARK: - Time Ago
Expand Down Expand Up @@ -56,16 +56,8 @@ extension Date {
var shortTimeAgoSinceNow: String {
return self.shortTimeAgo(since:Date())
}

func timeAgo(since date: Date) -> String {
return self.timeAgo(since: date, numericDates:false)
}

func timeAgo(since date: Date, numericDates: Bool) -> String {
return self.timeAgo(since: date, numericDates: numericDates, numericTimes:false)
}

func timeAgo(since date: Date, numericDates: Bool, numericTimes: Bool) -> String {
func timeAgo(since date:Date, numericDates: Bool = false, numericTimes: Bool = false) -> String {
let calendar = NSCalendar.current
let unitFlags = Set<Calendar.Component>([.second,.minute,.hour,.day,.weekOfYear,.month,.year])
let earliest = self.earlierDate(date)
Expand Down Expand Up @@ -202,12 +194,14 @@ extension Date {
}
}

internal func logicalLocalizedStringFromFormat(format: String, value: Int) -> String{

private func logicalLocalizedStringFromFormat(format: String, value: Int) -> String{
let localeFormat = String.init(format: format, getLocaleFormatUnderscoresWithValue(Double(value)))
return String.init(format: DateToolsLocalizedStrings(localeFormat), value)
}

internal func getLocaleFormatUnderscoresWithValue(_ value: Double) -> String{

private func getLocaleFormatUnderscoresWithValue(_ value: Double) -> String{
let localCode = Bundle.main.preferredLocalizations[0]
if (localCode == "ru" || localCode == "uk") {
let XY = Int(floor(value).truncatingRemainder(dividingBy: 100))
Expand Down
6 changes: 3 additions & 3 deletions DateTools/Enums.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

Further reading: [GitHub](https://github.com/MatthewYork/DateTools#relationships), [CodeProject](http://www.codeproject.com/Articles/168662/Time-Period-Library-for-NET)
*/
enum Relation {
public enum Relation {
case after
case startTouching
case startInside
Expand All @@ -38,15 +38,15 @@ enum Relation {

Open: The boundary moment of time represents a boundary value which is excluded in regard to calculations.
*/
enum Interval {
public enum Interval {
case open
case closed
}

/**
When a time periods is lengthened or shortened, it does so anchoring one date of the time period and then changing the other one. There is also an option to anchor the centerpoint of the time period, changing both the start and end dates.
*/
enum Anchor {
public enum Anchor {
case beginning
case center
case end
Expand Down
2 changes: 1 addition & 1 deletion DateTools/Integer+DateTools.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import Foundation

extension Int {
public extension Int {

//MARK: TimePeriod
var seconds: TimeChunk {
Expand Down
2 changes: 1 addition & 1 deletion DateTools/String+DateTools.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import UIKit

extension String {
public extension String {
init(_ date: Date) {
self = "\(date)"
}
Expand Down
2 changes: 1 addition & 1 deletion DateTools/TimeChunk.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import Foundation

struct TimeChunk {
public struct TimeChunk {

// MARK: - Variables

Expand Down
2 changes: 1 addition & 1 deletion DateTools/TimeInterval+Conversion.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import Foundation

extension TimeInterval {
public extension TimeInterval {

var seconds: Double {
return self
Expand Down
10 changes: 5 additions & 5 deletions DateTools/TimePeriod.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import Foundation

[Visit our github page](https://github.com/MatthewYork/DateTools#time-periods) for more information.
*/
protocol TimePeriodProtocol {
public protocol TimePeriodProtocol {

// MARK: - Variables

Expand All @@ -31,7 +31,7 @@ protocol TimePeriodProtocol {
var end: Date? {get set}
}

extension TimePeriodProtocol {
public extension TimePeriodProtocol {


// MARK: - Information
Expand Down Expand Up @@ -188,17 +188,17 @@ extension TimePeriodProtocol {

[Visit our github page](https://github.com/MatthewYork/DateTools#time-periods) for more information.
*/
class TimePeriod: TimePeriodProtocol {
open class TimePeriod: TimePeriodProtocol {

/**
The start date for a TimePeriod representing the starting boundary of the time period
*/
var beginning: Date?
public var beginning: Date?

/**
* The end date for a TimePeriod representing the ending boundary of the time period
*/
var end: Date?
public var end: Date?

// MARK: - Initializers

Expand Down
6 changes: 3 additions & 3 deletions DateTools/TimePeriodChain.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Foundation

[Visit our github page](https://github.com/MatthewYork/DateTools#time-period-chains) for more information.
*/
class TimePeriodChain: TimePeriodGroup {
open class TimePeriodChain: TimePeriodGroup {

// MARK: - Chain Existence Manipulation

Expand Down Expand Up @@ -79,11 +79,11 @@ class TimePeriodChain: TimePeriodGroup {
updateExtremes()
}

internal override func map<T>(_ transform: (TimePeriodProtocol) throws -> T) rethrows -> [T] {
public override func map<T>(_ transform: (TimePeriodProtocol) throws -> T) rethrows -> [T] {
return try periods.map(transform)
}

internal override func filter(_ isIncluded: (TimePeriodProtocol) throws -> Bool) rethrows -> [TimePeriodProtocol] {
public override func filter(_ isIncluded: (TimePeriodProtocol) throws -> Bool) rethrows -> [TimePeriodProtocol] {
return try periods.filter(isIncluded)
}

Expand Down
2 changes: 1 addition & 1 deletion DateTools/TimePeriodCollection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Foundation

[Visit our github page](https://github.com/MatthewYork/DateTools#time-period-collections) for more information.
*/
class TimePeriodCollection: TimePeriodGroup {
open class TimePeriodCollection: TimePeriodGroup {

// MARK: - Collection Manipulation

Expand Down
12 changes: 6 additions & 6 deletions DateTools/TimePeriodGroup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Foundation

[Visit our github page](https://github.com/MatthewYork/DateTools#time-period-groups) for more information.
*/
class TimePeriodGroup: Sequence {
open class TimePeriodGroup: Sequence {

// MARK: - Variables

Expand Down Expand Up @@ -52,27 +52,27 @@ class TimePeriodGroup: Sequence {

// MARK: - Sequence Protocol

func makeIterator() -> IndexingIterator<Array<TimePeriodProtocol>> {
public func makeIterator() -> IndexingIterator<Array<TimePeriodProtocol>> {
return periods.makeIterator()
}

internal func map<T>(_ transform: (TimePeriodProtocol) throws -> T) rethrows -> [T] {
public func map<T>(_ transform: (TimePeriodProtocol) throws -> T) rethrows -> [T] {
return try periods.map(transform)
}

internal func filter(_ isIncluded: (TimePeriodProtocol) throws -> Bool) rethrows -> [TimePeriodProtocol] {
public func filter(_ isIncluded: (TimePeriodProtocol) throws -> Bool) rethrows -> [TimePeriodProtocol] {
return try periods.filter(isIncluded)
}

internal func reduce<Result>(_ initialResult: Result, _ nextPartialResult: (Result, TimePeriodProtocol) throws -> Result) rethrows -> Result {
return try periods.reduce(initialResult, nextPartialResult)
}

func forEach(_ body: (TimePeriodProtocol) throws -> Void) rethrows {
public func forEach(_ body: (TimePeriodProtocol) throws -> Void) rethrows {
return try periods.forEach(body)
}

func split(maxSplits: Int, omittingEmptySubsequences: Bool, whereSeparator isSeparator: (TimePeriodProtocol) throws -> Bool) rethrows -> [AnySequence<TimePeriodProtocol>] {
public func split(maxSplits: Int, omittingEmptySubsequences: Bool, whereSeparator isSeparator: (TimePeriodProtocol) throws -> Bool) rethrows -> [AnySequence<TimePeriodProtocol>] {
return try periods.split(maxSplits: maxSplits, omittingEmptySubsequences: omittingEmptySubsequences, whereSeparator: isSeparator)
}

Expand Down

0 comments on commit 36ee1de

Please sign in to comment.