SkillAgentSearch skills...

SHNDDateFormatter

With this library you can convert your Numbers and your Date Strings that comes from API to any kinda Format , any locale and any calender that you need

Install / Use

/learn @shndrs/SHNDDateFormatter

README

SHNDDateFormatter

swift-version Version License Platform release-date

<img src="https://raw.githubusercontent.com/CocoaPods/shared_resources/master/img/CocoaPods-Logo-Highlight.png" width="128px" height="32px" />

How to Use

<p>Actually it's so simple:</p>

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. 😊😊

<p>Let's import SHNDDateFormatter</p>
import SHNDDateFormatter

<p>Then 👇🏻</p>
    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

<p>iOS 9.0+</p> <p>Xcode 10.1</p> <p>Swift 4.0 or later</p>

Installation

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

pod 'SHNDDateFormatter'

Author

sahandraeisi1994@gmail.com, sahandraeisi@yahoo.com

License

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

Related Skills

View on GitHub
GitHub Stars8
CategoryDevelopment
Updated4y ago
Forks2

Languages

Swift

Security Score

75/100

Audited on Mar 16, 2022

No findings