NSDateFormatter 使用哪个版本的 UTS-35?
Which version of UTS-35 does NSDateFormatter use?
我想在 NSDateFormatter(或 Swift 中的 DateFormatter)上使用 dateFormat
参数来使用 yyyy-MM-dd
等字符串模板格式化日期。我意识到这来自 UTS-35,但我不确定我的 OS 使用的是哪个版本的标准。
曾经有一个页面明确指定 Unicode Technical Standard #35 每个版本 iOS 支持哪个版本。我再也找不到 Apple 文档中的那个页面了。
最新的几个 iOS 版本使用哪个版本的 UTS-35?
搜索关键词:日期时间格式apple nsdate
Date Formatting Guide 有我要找的页面:
Fixed Formats
To specify a custom fixed format for a date formatter, you use setDateFormat:
. The format string uses the format patterns from the Unicode Technical Standard #35. The version of the standard varies with release of the operating system:
- OS X v10.9 and iOS 7 use version tr35-31.
- OS X v10.8 and iOS 6 use version tr35-25.
- iOS 5 uses version tr35-19.
- OS X v10.7 and iOS 4.3 use version tr35-17.
- iOS 4.0, iOS 4.1, and iOS 4.2 use version tr35-15.
- iOS 3.2 uses version tr35-12.
- OS X v10.6, iOS 3.0, and iOS 3.1 use version tr35-10.
- OS X v10.5 uses version tr35-6.
- OS X v10.4 uses version tr35-4.
所以您很可能正在寻找 version tr35-31 以获取任何最新的 iOS 版本。
但是,如 dateFormat
documentation 所述,如果您要向用户显示日期,最好完全避免使用 dateFormat
参数并使用 dateStyle
和 timeStyle
考虑到用户的 locale/preferences.
You should only set this property when working with fixed format representations, as discussed in Working With Fixed Format Date Representations. For user-visible representations, you should use the dateStyle
and timeStyle
properties, or the setLocalizedDateFormatFromTemplate:
method if your desired format cannot be achieved using the predefined styles; both of these properties and this method provide a localized date representation appropriate for display to the user.
我想在 NSDateFormatter(或 Swift 中的 DateFormatter)上使用 dateFormat
参数来使用 yyyy-MM-dd
等字符串模板格式化日期。我意识到这来自 UTS-35,但我不确定我的 OS 使用的是哪个版本的标准。
曾经有一个页面明确指定 Unicode Technical Standard #35 每个版本 iOS 支持哪个版本。我再也找不到 Apple 文档中的那个页面了。
最新的几个 iOS 版本使用哪个版本的 UTS-35?
搜索关键词:日期时间格式apple nsdate
Date Formatting Guide 有我要找的页面:
Fixed Formats
To specify a custom fixed format for a date formatter, you use
setDateFormat:
. The format string uses the format patterns from the Unicode Technical Standard #35. The version of the standard varies with release of the operating system:
- OS X v10.9 and iOS 7 use version tr35-31.
- OS X v10.8 and iOS 6 use version tr35-25.
- iOS 5 uses version tr35-19.
- OS X v10.7 and iOS 4.3 use version tr35-17.
- iOS 4.0, iOS 4.1, and iOS 4.2 use version tr35-15.
- iOS 3.2 uses version tr35-12.
- OS X v10.6, iOS 3.0, and iOS 3.1 use version tr35-10.
- OS X v10.5 uses version tr35-6.
- OS X v10.4 uses version tr35-4.
所以您很可能正在寻找 version tr35-31 以获取任何最新的 iOS 版本。
但是,如 dateFormat
documentation 所述,如果您要向用户显示日期,最好完全避免使用 dateFormat
参数并使用 dateStyle
和 timeStyle
考虑到用户的 locale/preferences.
You should only set this property when working with fixed format representations, as discussed in Working With Fixed Format Date Representations. For user-visible representations, you should use the
dateStyle
andtimeStyle
properties, or thesetLocalizedDateFormatFromTemplate:
method if your desired format cannot be achieved using the predefined styles; both of these properties and this method provide a localized date representation appropriate for display to the user.