Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Swift timeAgo returns empty string. #90

Open
jacks205 opened this issue Sep 28, 2015 · 6 comments
Open

Swift timeAgo returns empty string. #90

jacks205 opened this issue Sep 28, 2015 · 6 comments

Comments

@jacks205
Copy link

I am calling timeAgo from NSDate and it returns an empty string.

if let validDate = lastUpdated{
    let dateText = validDate.timeAgo
    self.updatedLabel.text = dateText
    print(validDate.timeAgo)
}

I tried to debug the Swift extension and found it gets an empty string there.

screen shot 2015-09-28 at 3 16 46 pm

This is how I am creating my NSDate if it is important:

let dateFormatter: NSDateFormatter = NSDateFormatter()
dateFormatter.locale = NSLocale(localeIdentifier: "en_US_POSIX")
dateFormatter.timeZone = NSTimeZone(abbreviation: "UTC")
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSX"
if let date = dateFormatter.dateFromString(dateString) {
    // I get valid a NSDate object
}
@victtavares
Copy link

Hi jack,

Did you import the .bundle folder into your project? It was also returning an empty string for me before I do it.

@jacks205
Copy link
Author

jacks205 commented Oct 5, 2015

No I just added the pod. That could be the issue.

@slangley
Copy link

slangley commented Nov 5, 2015

Under Cocoapods and Swift you are likely using use_frameworks. The currently released version on Cocoapods uses the main bundle as the location for the resource bundle, which will be broken when frameworks are used.

This issue seems to be fixed in the most recent master branch, so as a workaround until it's released, try a git repo line in your Podfile

@shafqat-muneer
Copy link

@jacks205 is empty string issue resolved? As i am still getting it. Thanks

@jacks205
Copy link
Author

@shafqat-muneer I'm not sure about the state of the pod, but I opted using this fuction someone put into a gist.

@khakha010
Copy link

let dateFormatter: NSDateFormatter = NSDateFormatter()
dateFormatter.locale = NSLocale(localeIdentifier: "en_US_POSIX")
dateFormatter.timeZone = NSTimeZone(abbreviation: "UTC")
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSX"
if let date = dateFormatter.dateFromString(dateString) {
// I get valid a NSDate object
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants