rengel

rengel

Yacco - Yet another calendar converter

Yacco will be a visual calendar converter written in Elixir and Phoenix based on my packages Calixir and Calendars.

First Post!

rengel

rengel

2020-07-31

An Engineering Notebook (ENB)

I’m not a newbie when it comes to software development. But I’m an absolute beginner when it comes to Phoenix/LiveView.

This is my first attempt to create something useful in Elixir/Phoenix/LiveView. I don’t yet know where this journey will end. I consider my posts in this thread as a progress report or as something like an ENB (Engineering Notebook) where I record my design reasoning and decisions.

This idea of an ENB fascinates me. I came across this idea on the Leo Google group. Leo is a Python-based outliner/IDE/development platform. In this group, the creator of Leo, Edward K. Ream, frequently writes up his reasoning about certain aspects of Leo for everybody to see and invites comments. So an outsider can better understand why what is done or left out (example).

I’ve done some prior work in this field. Out of some nostalgia and for documentation, a horribly buggy version of a Javascript-based calendar converter is included in assets/javascript/index.html. The whole user interface (mainly entry and display fields) and the scripts (calendar conversions) are contained in this single file. You can double-click on this file to open it in a browser. Its interface gives you some idea what Yacco will look like.

As Yacco will be based on my packages Calixir and Calendars I will try to show all the calendars contained in these package on one page. Changing but one field of one calendar should result in an update of all the fields of all the other calendars.

I don’t yet know how to achieve this in Phoenix, but first I want to try two approaches:

  • Put every field of every calendar in its own process or agent, or
  • put every every calendar with its subfields in its own process or agent.

The main idea of any reasonable calendar converter is to use a denominator that is common to all calendars. In Calixir and Calendars, this is the RataDieor fixed date. This is an artificial common denominator created by Dershowitz and Reingold in their book Calendrical Calculations. Alternately - and my preference - the Julian Day or JD was and is used, i.e. in astronomical calendars. Conversions between RataDie and JD are trivial.

The main interaction

A conversion using Yacco translates roughly into the folling steps:

  • User enters a field of a calendar (any calendar).
    • This triggers an on_field_enter event that will store the current value of this field
      in a temporary variable.
  • User inputs some data in the field.
  • User leaves the field.
    • This triggers an on_field_left event.
    • The event_handler will compare the old and the new value of this field.
      • If they are the same, the event_handler just exits.
      • If they are different, the event_handler continues.
    • The event_handler will validate the new date.
      • On :error it will display an error message replace the new value with the new and put the cursor back into the field.
      • On :ok it it will recalculate the fixed date corresponding to the new date using its to_fixed function and brodcast the new fixed date to the other calendars.
    • Each other calendar recalculates its native date using its from_fixed function and puts it into its display fields.
  • Loop repeats or user exits.

TODO: Handle different on_field_left event`s, i.e.

  • an on-escape should leave the date unchanged

How to proceed

As the ‘business logic’ or ‘model’ (the calendar conversions) are all done and via Calendars available, there remain two main tasks:

  • Implement the user interface (the View).
  • Implement the controller.

I’ll begin with the View, because…
Show the user as soon as possible, what the product will look like.

Where Next?

Popular in Discussions Top

Donovan
Hello everyone, I’m so glad to have discovered this awesome community. Thanks for creating it! This is my second post, and apologies for...
New
thojanssens1
It would be nice to be able to define a redirect from one route to another from the router.ex file. E.g.: redirect "/", UserController, ...
New
crispinb
On reading dhh’s latest The One Person Framework it strikes me that Phoenix with LiveView is already pretty much this. However, never hav...
New
AstonJ
I’ve just started the Phoenix part of the utterly brilliant online course by @pragdave. On generating the Phoenix app he uses the --no-ec...
New
CharlesO
Erlang :list.nth simple, but 1 - based nth(1, [H|_]) -> H; nth(N, [_|T]) when N > 1 -> nth(N - 1, T). Elixir Enum.at … coo...
New
fireproofsocks
I’ve been working on an Elixir project that has required a lot of scripting. I usually reach for Elixir because I like it more (and in th...
New
Qqwy
I would like to spark a discussion about the static access operator: .. For whom does not know: it is used in Elixir to access fields of...
New
joeerl
I’m playing with Elixir - It’s fun. I think @rvirding does give Elixir courses these days. Re: files and database - when I given Erlang ...
New
New
kostonstyle
Hi all How can I compare haskell with elixir, included tools, webservices, ect. Thanks
New

Other popular topics Top

danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 29603 241
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
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