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/SHNDDateFormatterREADME
SHNDDateFormatter
<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
node-connect
346.8kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
107.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
346.8kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
346.8kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
