Welcome to the documentation for mhprettydate – a library for formatting dates and times in a human-friendly manner.
With mhprettydate, you can easily display dates and times in a way that is more natural and easy to understand for users. By leveraging the library’s functions, you can convert complex date and time formats into simple and concise representations.
Features
- Converts standard date and time formats into human-friendly text
- Supports multiple languages for localized output
- Handles relative dates, such as “2 minutes ago” or “yesterday”
- Flexible formatting options for customization
Installation
- Install via CocoaPods:
pod 'mhprettydate'
Usage
To start using mhprettydate in your project, follow these steps:
- Import the library:
import mhprettydate
- Formatting a date:
let formattedDate = MHPrettyDate.format(date: yourDate)
- Formatting with options:
let formattedDateWithOptions = MHPrettyDate.format(date: yourDate, options: formattingOptions)
Localizations
mhprettydate supports multiple languages for localized date and time formatting. To use a specific language, follow these steps:
- Import the corresponding localization file:
import mhprettydate_localization_XX
- Set the localization for the library:
MHPrettyDate.setLocalization("XX")
Customization
mhprettydate offers customization options to tailor the formatting to your specific needs. You can customize:
- Date and time formats
- Captions for relative dates
To customize mhprettydate, follow these steps:
- Create a
MHPrettyDateOptions
object:
let customizationOptions = MHPrettyDateOptions()
- Set the desired options:
customizationOptions.dateFormat = "dd/MM/yyyy"
customizationOptions.relativeFormatYesterday = "Yesterday"
...
- Pass the options to the formatting function:
let formattedDateWithCustomOptions = MHPrettyDate.format(date: yourDate, options: customizationOptions)
That covers the basic usage and customization options provided by mhprettydate. Feel free to explore more advanced features and options by referring to the library’s documentation on GitHub.
GitHub repository: https://github.com/example/mhprettydate
Documentation on GitHub: https://github.com/example/mhprettydate#readme