Giter Club home page Giter Club logo

shnddateformatter's Introduction

SHNDDateFormatter

swift-version Version License Platform release-date

How to Use

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.

shnddateformatter's People

Contributors

shndrs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.