Skip to content

Instantly share code, notes, and snippets.

@PaulWoodIII
Created September 5, 2016 19:15
Show Gist options
  • Select an option

  • Save PaulWoodIII/c84def3aaf204148bf81a4b67bb64497 to your computer and use it in GitHub Desktop.

Select an option

Save PaulWoodIII/c84def3aaf204148bf81a4b67bb64497 to your computer and use it in GitHub Desktop.
Get all NSTimeZones and turn it into a usable Dictionary
//: # TimeZones
import Foundation
let tzs = NSTimeZone.knownTimeZoneNames()
var seperated : [String:Array<String>] = [String:[String]]()
func addToSeperated(_ region : String,_ place:String) -> Void {
if let _ = seperated[region] {
}
else {
seperated[region] = Array<String>()
}
seperated[region]!.append(place)
print(seperated[region]!.count)
}
for string in tzs {
let parsed = string.componentsSeparatedByString("/")
print(parsed)
guard parsed.count == 2 else {
continue
}
let region = parsed[0]
let specific = parsed[1]
addToSeperated(region,specific)
}
print(seperated)
@PaulWoodIII
Copy link
Author

bad variable names like seperated, but hey it'll get you there!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment