Created
November 13, 2015 02:25
-
-
Save manchan/3a8cb60694dc7ff84ef7 to your computer and use it in GitHub Desktop.
RSSで取得したpubDateをNSDateFormatterで変換(Swift) ref: http://qiita.com/you_matz/items/ccbf337222b2cb98e65b
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// string = "Wed, 04 Nov 2015 15:02:11 +0000" | |
let identifier = NSLocale.currentLocale().localeIdentifier | |
if identifier == "ja_JP" { | |
let dateFormatter = NSDateFormatter() | |
// 書式が変わらない固定ロケールで一度値を取得 | |
dateFormatter.locale = NSLocale(localeIdentifier: "en_US_POSIX") | |
dateFormatter.dateFormat = "EEE, dd MMM yyyy HH:mm:ss ZZZZ" | |
let r_date = dateFormatter.dateFromString(string!) | |
if let d = r_date { | |
// ロケールを日本語にして曜日を取得 | |
dateFormatter.locale = NSLocale(localeIdentifier: "ja_JP") | |
dateFormatter.dateFormat = "MM月dd日(E)" | |
tmpEntry.addObject(dateFormatter.stringFromDate(d)) | |
} | |
} | |
// 日本語以外 | |
else{ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment