Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jalaali/elixir-jalaali
Jalaali (also known as Jalali, Persian, Khorshidi, Shamsi) calendar implementation in Elixir.
https://github.com/jalaali/elixir-jalaali
calendar convert-dates date datetime elixir jalaali khorshidi shamsi
Last synced: about 1 month ago
JSON representation
Jalaali (also known as Jalali, Persian, Khorshidi, Shamsi) calendar implementation in Elixir.
- Host: GitHub
- URL: https://github.com/jalaali/elixir-jalaali
- Owner: jalaali
- License: mit
- Created: 2016-12-18T13:31:37.000Z (almost 8 years ago)
- Default Branch: main
- Last Pushed: 2023-09-11T20:20:39.000Z (over 1 year ago)
- Last Synced: 2024-09-21T22:07:50.724Z (3 months ago)
- Topics: calendar, convert-dates, date, datetime, elixir, jalaali, khorshidi, shamsi
- Language: Elixir
- Homepage: https://hex.pm/packages/jalaali
- Size: 62.5 KB
- Stars: 22
- Watchers: 4
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- freaking_awesome_elixir - Elixir - Jalaali calendar implementation for Elixir. (Date and Time)
- fucking-awesome-elixir - jalaali - Jalaali calendar implementation for Elixir. (Date and Time)
- awesome-elixir - jalaali - Jalaali calendar implementation for Elixir. (Date and Time)
README
# Elixir Jalaali calendar
![Build Status](https://github.com/jalaali/elixir-jalaali/actions/workflows/ci.yaml/badge.svg)
[![Hex.pm](https://img.shields.io/hexpm/v/jalaali.svg)](https://hex.pm/packages/jalaali)
[![GitHub license](https://img.shields.io/badge/license-MIT-green.svg)](https://raw.githubusercontent.com/jalaali/elixir-jalaali/master/LICENSE)
[![GitHub issues](https://img.shields.io/github/issues/jalaali/elixir-jalaali.svg)](https://github.com/jalaali/elixir-jalaali/issues)Elixir implementation of [jalaali.js](https://github.com/jalaali/jalaali-js) which contains a Calendar implementation for jalaali and some functions for converting Jalaali and Gregorian calendar systems to each other.
## Installation
You can install `jalaali` by Addding it to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:jalaali, "~> 0.4"}
]
end
```## Usage
After installing jalaali package. you can create Dates/DateTimes in jalaali or convert
Dates/DateTimes form other calendars back an forth.### How to use
- Creating new Date
```elixir
Date.new(1396, 6, 30, Jalaali.Calendar)
{:ok, %Date{calendar: Jalaali.Calendar, day: 30, month: 6, year: 1396}}
```- Converting a DateTime to Jalaali
```elixir
datetime_in_any_calendar = DateTime.utc_now(Calendar.ISO)
{:ok, jalaali_datetime} = DateTime.convert(datetime_in_any_calendar, Jalaali.Calendar)
```- Converting a DateTime from Jalaali
```elixir
jalaali_datetime = DateTime.utc_now(Jalaali.Calendar)
{:ok, iso_datetime} = DateTime.convert(jalaali_datetime, Calendar.ISO)
```- Converting a Date to Jalaali
```elixir
date_in_any_calendar = Date.new(2017, 1, 1, Calendar.ISO)
{:ok, jalaali_date} = Date.convert(date_in_any_calendar, Jalaali.Calendar)
```- Converting a Date from Jalaali
```elixir
{:ok, jalaali_date} = Date.new(1396, 6, 30, Jalaali.Calendar)
{:ok, iso_date} = Date.convert(jalaali_date, Calendar.ISO)
```Thats super easy. :)
## License
This project is license under MIT.
For more information please check [LICENSE](https://github.com/jalaali/elixir-jalaali/blob/master/LICENSE)