Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/sbytedev/net.mvvmcross.plugins.datetimeconverter

A set of date and time converters.
https://github.com/sbytedev/net.mvvmcross.plugins.datetimeconverter

c-sharp date-formatting mvvmcross plugin xamarin

Last synced: about 1 month ago
JSON representation

A set of date and time converters.

Awesome Lists containing this project

README

        

# MvvmCross DateTimeConverter Plugin
![GitHub](https://img.shields.io/github/license/SByteDev/Net.MvvmCross.Plugins.DateTimeConverter.svg)
![Nuget](https://img.shields.io/nuget/v/SByteDev.MvvmCross.Plugins.DateTimeConverter.svg)
[![CI](https://github.com/SByteDev/Net.MvvmCross.Plugins.DateTimeConverter/actions/workflows/ci.yml/badge.svg)](https://github.com/SByteDev/Net.MvvmCross.Plugins.DateTimeConverter/actions/workflows/ci.yml)
[![CD](https://github.com/SByteDev/Net.MvvmCross.Plugins.DateTimeConverter/actions/workflows/cd.yml/badge.svg)](https://github.com/SByteDev/Net.MvvmCross.Plugins.DateTimeConverter/actions/workflows/cd.yml)
[![CodeFactor](https://www.codefactor.io/repository/github/sbytedev/net.mvvmcross.plugins.datetimeconverter/badge)](https://www.codefactor.io/repository/github/sbytedev/net.mvvmcross.plugins.datetimeconverter)

Provides a set of native converters to convert DateTime into the user-friendly string.

## Installation

Use [NuGet](https://www.nuget.org) package manager to install this library.

```bash
Install-Package SByteDev.MvvmCross.Plugins.DateTimeConverter
```

## Usage
```cs
using SByteDev.MvvmCross.Plugins.DateTimeConverter;
```

### iOS
|Converter|Output|
|---------|------|
|DateTimeToLongDateString|Feb 3, 2020|
|DateTimeToLongDateTimeString|Feb 3, 2020 at 6:30:10 PM GMT+3|
|DateTimeToLongTimeString|6:30:10 PM GMT+3|
|DateTimeToMediumDateString|Feb 3, 2020|
|DateTimeToMediumDateTimeString|Feb 3, 2020 at 6:30:10 PM|
|DateTimeToMediumTimeString|6:30:10 PM|
|DateTimeToShortDateString|2/3/20|
|DateTimeToShortDateTimeString|2/3/20, 6:30 PM|
|DateTimeToShortTimeString|6:30 PM|
|DateTimeToRelativeDateTimeString|now,last week, etc.|

### Android
|Converter|Output|
|---------|------|
|DateTimeToDateString|February 3|
|DateTimeToDateTimeString|February 3, 6:30 PM|
|DateTimeToTimeString|6:30 PM|
|DateTimeToRelativeString|May 11, 2020|

## Implementation

### iOS

Uses [NSDateFormatter](https://developer.apple.com/documentation/foundation/nsdateformatter) and [NSRelativeDateTimeFormatter](https://developer.apple.com/documentation/foundation/nsrelativedatetimeformatter).

### Android

Uses [DateUtils](https://developer.android.com/reference/android/text/format/DateUtils).

## Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update the tests as appropriate.

## License
[MIT](https://choosealicense.com/licenses/mit/)