date

An article by Gaspard Bucher

Contextual Time value.

  1. action
  2. ajax
  3. API
  4. classes
  5. common attributes
  6. conditions
  7. context
  8. dates
    1. calendar
    2. date
    3. now
    4. parse_date
  9. display
  10. forms
  11. i18n
  12. meta
  13. SQLiss
  14. urls

Contextual Time value.

see parse_date, show, store, functions

This method retrieves the date passed as argument in the url or the current time.

some/url?date=2011-04-20T17:09

The date argument is encoded with the ISO format without timezone information:

"%Y-%m-%dT%H:%M:%S"

Contextual timezone

Please read this paragraphe…

If you use a contextual timezone (to present a calendar for public events for example), you should use date(tz) to ensure that the url date is parsed with the contextual timezone instead of the visitor’s.

<r:default tz='America/New_York'>
  <h3>Events on <r:date format='%m %d'/> (<r:tz/>)</h3>
  <ul do='events where event_date.date = #{date(tz)} in project'>
    <li do='each'>...</li>
  </ul>
</r:default>

If you are not familiar with the ”.date” macro in the query above, please read the chapter on SQLiss functions.

Usage in view

Example to display the date (not very useful on its own):

<b do='date' format='%Y-%m-%d'/>

Used to filter elements:

<ul do='notes where log_at.date = #{date} in site'>
  ...
</ul>

The above query uses the date SQLiss function.