Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add language support to represent the current date and time #40

Closed
thiagodp opened this issue May 5, 2019 · 2 comments
Closed

Add language support to represent the current date and time #40

thiagodp opened this issue May 5, 2019 · 2 comments
Assignees
Labels
assigned Somebody is working on this issue enhancement New feature or request feedback desired language Related to the Concordia Language

Comments

@thiagodp
Copy link
Owner

thiagodp commented May 5, 2019

Currently, Concordia relies on queries to get the current date, time or datetime. Examples:

- value comes from "SELECT CURRENT_DATE()"

- value comes from "SELECT CURRENT_TIME()"

- value comes from "SELECT NOW()"

Formatted values are also accepted:

# dd/mm/yyyy
- value comes from 'SELECT DATE_FORMAT( CURRENT_DATE(), "%d/%m/%Y")"

# hh:mm
- value comes from 'SELECT TIME_FORMAT( CURRENT_TIME(), "%h:%i")'

# dd/mm/yyyy hh:mm:ss
- value comes from 'SELECT DATE_FORMAT( NOW(), "%d/%m/%Y %h:%i:%s")'

Instead, it should support a declaration that produces the value without having to deal with queries.

Proposal

1. Language constructions for date and time

The proposed constructions should consider the property data type.
For example, now for a date must return the current date, while now for a time must return the current time.

Date constructions

  • now
  • current date
  • today
  • yesterday
  • tomorrow
  • next + ( week | month | year )
    Example: next week
  • last + ( week | month | year )
    Example: last month
  • number + ( day | days | week | weeks | year | years ) + ( ago | ahead | later )
    Example: 2 days ago

Time constructions

  • now
  • current time
  • current + ( second | minute | hour )
  • number + ( second | seconds | minute | minutes | hour | hours ) + ( ago | ahead | later )
    Example: 1 second ago

Datetime constructions

  • current datetime
  • all the date and time constructions

2. Allow constructions for integer values

Example:

UI Element: Sales Last Year
  - data type is integer
  - max value is the current year # current year value, like 2019

UI Element: Meeting Day
  - data type is integer
  - max value is today  # current day value, like 25

Some Examples

UI Element: Meeting Date
  - data type is date
  - min value is today

UI Element: Sales Last Year
  - data type is integer
  - max value is this year # current year value

UI Element: Birth Date
  - data type is date
  - max value is 18 years ago # the current date, but for 18 years ago
    Otherwise I see "You must be at least 18 years old."

Future work

👉 New Issues may address them.

1. Built-in functions date(), time(), and datetime()

  • Both can receive an optional parameter format. Its value should default to the UI Element locale's date/time/datetime format, if available in the language (see Add locale support to date and time types #30). Otherwise, the locale defined by the document's language.

  • The parameter format should use the PHP format for date and time values.

  • By default, date() should return day, month and year. Example for the English locale: 12/31/2018.

  • By default, time() should return hour and minute (without second). Example for the Portuguese locale: 13:00.

  • By default, datetime() should return day, month, year, hour, minute and second. Example for the English locale: 12/31/2018 10:20:30.

2. Allow to use the proposed functions inside declared tables.

3. Allow time zones (as an additional optional parameter for the functions?).

@thiagodp thiagodp self-assigned this May 5, 2019
@thiagodp thiagodp added enhancement New feature or request language Related to the Concordia Language priority High priority labels May 5, 2019
@thiagodp thiagodp removed the priority High priority label May 17, 2019
@thiagodp thiagodp changed the title Add language support to current date and time Add language support to represent the current date and time May 22, 2019
@thiagodp thiagodp added the assigned Somebody is working on this issue label Apr 29, 2020
@thiagodp thiagodp mentioned this issue May 3, 2020
89 tasks
@thiagodp
Copy link
Owner Author

This feature is being released with Concordia 2.

Constructions for integer values were changed. For date or datetime, you can use day of, month of or year of plus a date expression. Example: - minimum value is year of last year. For time or datetime, you can use hour of, minute of or second of plus a time expression. Example: - maximum value is hour of 2 hours ago.

Built-in date and time functions will be implemented in the future, as suggested.

@thiagodp
Copy link
Owner Author

Released in 2.0-alpha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
assigned Somebody is working on this issue enhancement New feature or request feedback desired language Related to the Concordia Language
Projects
None yet
Development

No branches or pull requests

1 participant