MycroftAI / lingua-franca

Mycroft's multilingual text parsing and formatting library
Apache License 2.0
75 stars 79 forks source link

Migrate or implement formatters from official datetime skill #198

Open ChanceNCounter opened 3 years ago

ChanceNCounter commented 3 years ago

The official DateTime Skill currently contains some nifty get_x() functions for relevant information, most of which just expose things from Lingua Franca. Others retrieve info from LF and then mutate it a bit. Clever little formatters.

These are very useful to other Skills, and not only Skills! I became aware of them because @AIIX used them for home screen info. Anything that wants to display the date or a schedule could benefit, so I think LF should support that stuff directly. We're halfway there already with nice_time().

We could start by simply migrating the functions from the Skill and seeing if anything even needs further localization. At a glance, it looks like it's built around lingua_franca.format.date_time_format.

@chrisveilleux thoughts from the Skill side of things?

krisgesling commented 3 years ago

Yeah this seems like a good thing to pull out, I can imagine many things wanting to have a nice looking day / date / month and whilst the Skills API is great, these would be broadly used including outside Mycroft.

Would the following cover everything?

Given nice_day and nice_year would both be wrapping a single .strftime() call it doesn't seem necessary to add these. And I would see the lingua_nostra.format.nice_day(dt, include_month=True) being covered by nice_display_date()

In nice_display_date(), should we take in a format that matches either strftime, "DMY", or "MDY"?

I can see the leap year stuff fitting into the current time.py however for me it also doesn't seem to fit into the scope of Lingua Franca as a formatting and parsing library. We could add it to mycroft.util.time but I can't imagine it getting used a lot. Maybe this is one that makes sense being in the Skill and exposed via the Skill API.

chrisveilleux commented 3 years ago

I will be looking at the date/time skill next week to give it some much needed TLC. Once I've had a chance to familiarize myself with the skill again I will provide some feedback.