Latest 1.0.8
Homepage https://github.com/shndrs/SHNDDateFormatter
License MIT
Platforms ios 9.3, watchos 3.2, tvos 10.2
Frameworks Foundation
Authors

CI Status
Version
License
Platform

SHNDDateFormatter SHNDDateFormatter

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Actually it’s so simple:

First you should build an object of what kinda format that you want, then use it wherever you want,
in example i just printed it. 😊😊

Let’s import SHNDDateFormatter

import SHNDDateFormatter

Then 👇🏻

    let builderObject = DateBuilder { (builder) in

        builder.inputDateString = "01-01-2019"
        builder.inputDateFormat = "MM-dd-yyyy"
        builder.outputDateFormat = "MMM d, yyyy"
        builder.inputCalenderIdentifier = .gregorian
        builder.outputCalenderIdentifier = .chinese
        builder.outputLocale = "zh_Hans_CN"
    }

    let stringConvertedDate = SHNDDateFormatter(builder: builderObject)?.build()
    print(stringConvertedDate)

inputString = "01-01-2019", outputString = "冬月 26, 0035"

SHNDNumberFormatter


let builderObject = NumberBuilder { (builder) in
    builder.locale = "en_US"
    builder.number = NSNumber(value: 150000.45)
    builder.numberStyle = .currencyPlural
}

let convertedValue = SHNDNumberFormatter(builder: builderObject)?.convert()
print(convertedValue)

inputNumber = 150000.45 ,
outputString = "150,000.45 US dollars"


let builderObject = NumberBuilder { (builder) in
    builder.locale = "fa_IR"
    builder.number = NSNumber(value: 0.15)
    builder.numberStyle = .percent
}

let convertedValue = SHNDNumberFormatter(builder: builderObject)?.convert()
print(convertedValue)

inputNumber = 0.15 ,
outputString = "۱۵%"

input = 1235

Style en_US Locale fa_IR Locale
.none nil nil
.decimal 1,235 ۱٬۲۳۵
.percent 123,500% ۱۲۳٬۵۰۰٪
.scientific 1.235E3 ۱٫۲۳۵×۱۰^۳
.spellOut one thousand two hundred thirty-five یک هزار و دویست و سی و پنج
.ordinal 1,235th ۱٬۲۳۵.
.currency $1,235.00 ریال۱٬۲۳۵
.currencyAccounting $1,235.00 ‎ریال ۱٬۲۳۵
.currencyISOCode USD1,235.00 IRR۱٬۲۳۵
.currencyPlural 1,235.00 US dollars ۱٬۲۳۵ ریال ایران

Just enter your locale and enjoy 😉.
More about NumberFormatter.Style 👉🏻 Apple Document

Requirements

iOS 9.0+

Xcode 10.1

Swift 4.0 or later

Installation

SHNDDateFormatter is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'SHNDDateFormatter'

Author

[email protected], [email protected]

License

SHNDDateFormatter is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "SHNDDateFormatter",
    "version": "1.0.8",
    "summary": "Simple swift date string convertor",
    "description": "With this library you can convert your Date Strings that comes from API or anywhere else to any kinda Format , any kinda locale and any kinda calender that you need",
    "homepage": "https://github.com/shndrs/SHNDDateFormatter",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "[email protected]": "[email protected]"
    },
    "source": {
        "git": "https://github.com/shndrs/SHNDDateFormatter.git",
        "tag": "1.0.8"
    },
    "social_media_url": "https://linkedin.com/in/shndrs",
    "platforms": {
        "ios": "9.3",
        "watchos": "3.2",
        "tvos": "10.2"
    },
    "swift_version": "4.0",
    "source_files": "SHNDDateFormatter/Classes/**/*",
    "frameworks": "Foundation"
}

Pin It on Pinterest

Share This