Skip to content

Instantly share code, notes, and snippets.

@aoenth
Last active February 24, 2020 20:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aoenth/56cae8e5e4e68007faa6bbe8b5529af8 to your computer and use it in GitHub Desktop.
Save aoenth/56cae8e5e4e68007faa6bbe8b5529af8 to your computer and use it in GitHub Desktop.
guard let hyphen = chineseDate.firstIndex(of: "-") else {
fatalError("\(chineseDate) is not correctly formatted, use DateFormatter.Style.full")
}
let startIndex = chineseDate.index(after: hyphen)
let endIndex = chineseDate.index(chineseDate.endIndex, offsetBy: -2)
let branch = chineseDate[startIndex ... endIndex]
print(branch)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment