Skip to content

Clarify abbreviated, ambiguous and incomplete dates meanings according to cultural contexts.

License

Notifications You must be signed in to change notification settings

crgz/abbreviated_dates

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Release! Status Issues Forks Stargazers Contributors MIT License contributions welcome Ask Me Anything!

Abbreviated Date Parser

The Abbreviated Date Parser Library contains a predicate that parses abbreviated incomplete dates in multiple languages.

Getting Started

Imagine you want to understand the date: "11-09, št". We can infer that "št" is an abbreviation of:

findall([F,L,C],(parse(date(2022,09,9),'11-09, št',[D],_,L,C),format_time(string(F),"%A, %d %b %Y",D)),Y),cli_table(Y,[head(['Date','Language','Country'])]).
╔═══════════════════════╤════════════╤════════════════╗
║         Date          │  Language  │    Country     ║
╟───────────────────────┼────────────┼────────────────╢
║ Saturday, 09 Nov 2024 │ Lithuanian │   Lithuania    ║
║ Saturday, 11 Sep 2027 │ Lithuanian │     Latvia     ║
║ Thursday, 11 Sep 2025 │   Slovak   │ Czech Republic ║
║ Thursday, 11 Sep 2025 │   Slovak   │    Slovakia    ║
║ Thursday, 11 Sep 2025 │   Slovak   │ Czech Republic ║
║ Thursday, 11 Sep 2025 │   Slovak   │    Slovakia    ║
╚═══════════════════════╧════════════╧════════════════╝
  • Šeštadienis which means in Saturday in Lithuanian
  • Štvrtok which means in Thursday in Slovak

But Lithuanian is spoken not only in Lithuania but also in Latvia and Slovak is spoken not only in Slovakia but also by a minority in Czech Republic. These countries use different date representations: Czech Republic, Latvia and Slovakia have the day written first because of the "little" date endianness format used as the standard in the country. Lithuania, on the other hand, uses the "big" date endiannes format which means that the month is written first.

The system factor in all this facts and is able to come with the right answers:

In the case of interpreting the abbreviation as s Saturday:

  • 9 of November 2024
  • 11 of September 2027

In the case of interpreting the abbreviation as a Thursday:

  • 11 of September 2025

Getting Started

This pack is available from the add-on registry of SWI-Prolog.

It can be installed with pack_install/1:

?- pack_install(abbreviated_dates).

Then, you can use it by simply calling use_module(library(abbreviated_dates)).

parse(Context, Expression, Dates, Trace).

Prerequisites

For maintenance tasks bumpversion and hub might be required.

Installation

Usage

parse/4.  % parse an abbreviated incomplete date in multiple languages (today, tomorrow, etc).

For further details have a look at the implementation. In addition, the new might give an impression on how to use this library.

The tests can be run using the following command:

make test

Define new Tests

New tests should be defined in the test file.

Review: https://eu.swi-prolog.org/pack/review?p=abbreviated_dates

Roadmap

  • Multi-language Support
  • Add back to top links

See the open issues for a full list of proposed features (and known issues).

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the MIT License. See LICENSE file for more information.

(back to top)