25

GitHub - FormatterKit/DayPeriodFormatter: A formatter for localized day periods...

 4 years ago
source link: https://github.com/FormatterKit/DayPeriodFormatter
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

README.md

DayPeriodFormatter

import Foundation
import DayPeriodFormatter

let formatter = DayPeriodFormatter()
let dateComponents = DateComponents(hour: 9, minute: 41)
formatter.string(from: dateComponents) // "morning"

// 150+ locales supported
formatter.locale = Locale(identifier: "ja")
formatter.string(from: dateComponents) // "朝"

Requirements

  • Swift 4.0+

Installation

Swift Package Manager

Add the DayPeriodFormatter package to your target dependencies in Package.swift:

import PackageDescription

let package = Package(
  name: "YourProject",
  dependencies: [
    .package(
        url: "https://github.com/FormatterKit/DayPeriodFormatter",
        from: "0.0.1"
    ),
  ]
)

Then run the swift build command to build your project.

License

MIT

Contact

Mattt (@mattt)


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK