ravi11o

ravi11o

Datex - A simple user friendly date and time library

Datex is a user friendly simple date and time library which I build while learning elixir and phoenix. It deals with standard date and time formats along with elixir formats. It has functions for comparing, adding and formatting dates and time from standard formats to elixir and vice-versa. It provides super friendly comparison results like 3 days ago or 2 months later in date and like an hour ago in time. It even has functions which provides a date-list in desired format from a dateRange.

I know its not perfect but I have tried my best and I am open to suggestions and feedbacks.

Thanks!

Most Liked

ravi11o

ravi11o

@Eiji I am aware of timex and in no way it could stand among Timex or any such date time library like calendar.
As I have already mentioned I created it while learning and thought of maybe it could help some in the community. I had no intention of flooding the forum.

Anyways, as far as I know Timex functions deal with Erlang datetime tuples, Date, NaiveDateTime, and DateTime. Datex is simply for date and time and it has no support for datetime or naive yet. Here you don’t have to worry about formats like dd-mm-yyyy or yyyy/mm/dd as you can parse any date format. For example..

> Datex.Date.format_date("2017/2/10", "MONTH_NAME_FULL DATE YYYY") 
"February 10, 2017"

OR

> Datex.Date.format_date(~D[2019-02-10], "DAY_SHORT, DATE MONTH_NAME_SHORT")
"Sun, 10 Feb"

I have also tried relative date and time comparison inspired from momentjs. Again you don’t have to worry about formats. For example..

> Datex.Date.compare("15 aug 2018", ~D[2018-08-06])
"a week and 2 days later"

> Datex.Time.compare(~T[23:16:45], "15:34:25")
"7 hours and 42 minutes later"

It also supports a lot of different formats to work with on date and time.

Eiji

Eiji

@ravi11o Did you know about timex? I did not looked deep into your library, but it’s what comes to me while reading your description. In such cases community would like to know why did you created such library (like solve problem in different way than current implementation does) and how different it’s from other implementations (for example compare it to already mentioned by me timex). It would be helpful if in your post you will add this information.

Where Next?

Popular in Announcing Top

danschultzer
In short Plug n’ play OAuth 2.0 provider library. Just set up a resource owner schema with Ecto (your user schema), install the dependen...
New
bluzky
You may know https://ui.shadcn.com/, a UI component library for React. I really love it’s design style and components. I’ve built some co...
384 13736 119
New
Qqwy
Today I realized that it would be possible to implement currying-capability in Elixir, using some clever anonymous function creation. (‘c...
New
mbuhot
Leverage Open Api 3.0 (Swagger) to document, test, validate and explore your Plug and Phoenix APIs. Generate and serve a JSON Open API ...
New
type1fool
WebAuthnLiveComponent WebAuthnComponents See this post about renaming the package. Passwordless authentication for Phoenix LiveView app...
New
mindok
What is ContEx? A pure Elixir server-side data plotting/charting library outputting SVG. It has nice barcharts in particular and works g...
New
Azolo
Hey everyone, I just released WebSockex which is a Elixir WebSocket client. WebSockex strives to work as a OTP special process, be RFC6...
New
zachdaniel
Ash Framework What is Ash? Ash Framework is a declarative, resource-oriented application development framework for Elixir. A resource can...
New
woylie
I released Doggo, a collection of unstyled Phoenix components. https://github.com/woylie/doggo Features Unstyled Phoenix components....
New
zoltanszogyenyi
Hey everyone :waving_hand: Excited to join this forum - I am one of the founders and current project maintainers of a popular and open-s...
New

Other popular topics Top

New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
AstonJ
Please see the new poll here: Which code editor or IDE do you use? (Poll) (2022 Edition) It’s been a while since we first asked this, I...
208 31142 143
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

We're in Beta

About us Mission Statement