Documatic Hackathon project submission
Documatic is a search engine for your codebase; Ask documatic a question and find relevant code snippets and insights in seconds.
https://www.documatic.com/ Documatic acts as a search engine for your codebase; once you describe what you're looking for, Documatic pulls up related code or documentation making it easier to find what you're looking for in seconds!
Not sitting next to each other? No problem. Ask Documatic questions of your codebase to learn and understand your code in seconds. Documatic is the team member you wish you had
Our Visual studio Code extension: https://marketplace.visualstudio.com/items?itemName=Documatic.documatic
This is a small utility that allows you to get a relative date from a given date, in a more customizable and rich way. It was built on the Luxon DateTime library.
date.plus({ days: 8 }).toRelativeCalendar()
// => "in 1 week"
date.plus({ days: 8 }).toRelativeCalendarAdvanced("{{[rpf]wd}} {{[at] h m}}")
// => "the next monday at 15:32"
date.plus({ days: 8 }).toRelativeCalendarAdvanced("The party will be {{[rpf]wd}} at {{h|f:1}} {{ampm}}, will you be coming?")
// -> "The party will be next monday at 3 PM, will you be coming?"
npm i luxon-advanced-relative-calendar
- Easy customization of simple or ultra complex relative dates
- Easy to learn syntax
- Numeric filters to format numeric values
- Smart H:M:S combo formatting
- Support for English and Spanish locales (carefully crafted by hand 😉)
luxon.DateTime.toRelativeCalendarAdvanced(format, [locale])
format
- The format string. See below for more info.locale
- The locale to use. Currently, there is support for Englishen
and Spanishes
. Defaults toen
.
The format string is a string that contains the desired output. It is composed of tokens and text. Tokens are enclosed in double curly braces {{}}
and text is everything else. Tokens are replaced by their corresponding value, and text is left as is.
General format: {{[prefix]value|filter:filterArg}}
Tokens are composed of 3 parts: prefix, value and filters. The prefix and the filter are optional, see below for a list of available prefixes and filters.
[at]
- Adds the appropiate article/preposition to the value to express relativity. For example,{{[at]h}} {{ampm}}
will returnat 3 PM
, and{{[at]wd}}
will returnon monday
.[rpf]
- Acts the same as the[at]
prefix, but it will return the relative past/future form of the value taking in account calendar days. For example,{{[rpf]wd}}
would returnyesterday
,today
,tomorrow
ornext monday
depending on the date given.
wd
- The weekday name. For example,{{wd}}
will returnmonday
.h
- The hour. For example,{{h}}
will return15
.m
- The minute. For example,{{m}}
will return32
.s
- The second. For example,{{s}}
will return12
.
|f:
- fill - This filters outputs a value with a desired amount of digits by adding zeroes. For example, for a time where the hour is3
,{{h|f:1}}
will return3
, and{{h|f:2}}
will return03
.
{{ampm}}
- This token will returnAM
orPM
depending on the hour given. For example,{{h m}} {{ampm}}
will return3:32 PM
.
DateTime.local().toRelativeCalendarAdvanced("{{[rpf]wd}} {{[at] h m}}")
// => "today at 15:32"
DateTime.local().minus({ days: 3 }).toRelativeCalendarAdvanced("Message sent {{[rpf]wd}}")
// => "Message sent this monday"
DateTime.local().plus({ days: 8 }).toRelativeCalendarAdvanced("{{[rpf]wd}} at {{m}} minutes and {{s|f:10}} seconds after {{h|f:2}} {{ampm}}")
// => "next monday at 32 minutes and 12 seconds after 03 PM"
DateTime.local().plus({ days: 8 }).toRelativeCalendarAdvanced("El estreno será {{[rpf]wd}} {{[at]h|f:2}}:{{m|f:2}} {{ampm}}", "es")
// => "El estreno será el próximo lunes a las 03:32 PM"
This project is licensed under the MIT License - see the LICENSE file for details
- This Stackoverflow comment p.d: RIP Mr. Alexei S. 3 years have passed 😂.
- I use luxon a lot, and I wanted to make it more customizable, specially for my language (Spanish).
*
This package is not yet published on npm, but it will be soon, hopefully