An open API service indexing awesome lists of open source software.

https://github.com/gocom/rah_get_date

Outputs date and time from the requested URL
https://github.com/gocom/rah_get_date

Last synced: 8 months ago
JSON representation

Outputs date and time from the requested URL

Awesome Lists containing this project

README

          

h1. rah_get_date

p. The plugin, rah_get_date, outputs date and time from the requested url. Supports "Textpattern's":http://www.textpattern.com build in @date@ and @month@ -GET variables, and outputs formatted date based on those two GET values. That way you can, for example, output month header to month separated article listing pages.

h2. List of features

* Output date from @?date=@ and/or @?month=@ get values.
* Format date just like you can with @@.

h2. Requirements

p. Minimum requirements:

* TXP 4.x.x+

p. Recommended:

* TXP 4.4.1 or newer.

h2. Installation and usage

p. The basic method stands: paste plugin code to the plugin install textarea and run the automatic setup. Activate the plugin, and you are ready to use the new tag, @@ like others.

h2. Attributes

The tag is @@ and attributes for it follow. All attributes are optional.

p. *format*
Date format used to output the date. Any valid "strftime()":http://php.net/strftime string value since "iso8601,":http://en.wikipedia.org/wiki/ISO_8601 w3cdtf, or "rfc822.":http://www.w3.org/Protocols/rfc822/#z28
Default: @format="%Y %B"@ Example: @"%Y %m %d"@.

p. *format_year*
Allows specific formatting for dates that only specify the year (@YYYY@). If the attribute is set, the additional formatting is used. Same formatting rules apply.
Default: @unset@ Example: @format_year="Articles posted during %Y"@

p. *format_month*
Allows specific formatting for dates that only specify the year and the month of the year (@YYYY-mm@). If the attribute is set, the additional formatting is used. Same formatting rules apply.
Default: @unset@ Example: @format_month="%B, %Y"@

p. *format_date*
Allows specific formatting for dates that only specify the year, the month and the day of the month (@YYYY-mm-dd@). If the attribute is set, the additional formatting is used. Same formatting rules apply.
Default: @unset@ Example: @format_date="%B %d, %Y"@

p. *format_hour*
Allows specific formatting for dates that only specify the year, month, day and hour of the day (@YYYY-mm-dd HH@). If the attribute is set, the additional formatting is used. Same formatting rules apply.
Default: @unset@ Example: @format_hour="Posted on %H of %d"@

p. *format_minute*
Allows specific formatting for dates that only specify the year, month, day, hours and minutes (@YYYY-mm-dd HH:MM@). If the attribute is set, the additional formatting is used. Same formatting rules apply.
Default: @unset@ Example: @format_minute="%H:%M"@

p. *format_second*
Allows specific formatting for dates that only specify the year, month, day, hours, minutes and seconds (@YYYY-mm-dd HH:MM:SS@). If the attribute is set, the additional formatting is used. Same formatting rules apply.
Default: @unset@ Example: @format_second="%Y %B, %d %H:%M:%S"@

p. *format_now*
Formatting used if the requested date is the current time. Current time's condition is set with the @now_condition@ attribute. By default, if the requested date/time is within the current day, the formatting defined in @format_now@ is used.
Default: @unset@ Example: @format_now="Articles posted today"@

p. *now_condition*
Defines what dates are considered as current time. Set the date format that is used in matching current and requested dates. By default matches days (today).
Default: @now_condition="%Y-%m-%d"@ Example: @"%Y-%m"@

h2. Examples

h3. Basic usage

bc.

p. Outputs @"2009 March"@ if requested URI is @http://mysite.com/path/?month=2009-3@.

h3. Use specific formatting for dates that only define the year

The example uses @format_year@ attribute to set the formatting for the dates that only specify the year.

bc.

p. Outputs @"2009 March"@ if the requested URL is @http://mysite.com/path/?month=2009-3@ and @"Posted during 2008"@ if the requested URL is @http://mysite.com/path/?month=2008@

h3. Output @"Posted today"@, if the requested timestamp is today.

bc.

h2. Changelog

h3. Version 0.2 - 2011/05/22

* Added: support for additional formatting rules applied based on timestamp's accuracy. Added attributes: @format_year@, @format_month@, @format_date@, @format_hour@, @format_minute@, @format_second@, @format_now@, @now_condition@ and @date@.
* Added: Ability to set the date using @date@ attribute in addition to the URL parameter.
* Now uses safe_strtotime() instead of strtotime() to format the dates.
* Now checks if the provided date is in valid strtotime() format.
* Skip date formatting if the resulting formatting string is empty.

h3. Version 0.1 - 2009/03/06

* First release.