Extension:DateDiff

From MediaWiki.org
Jump to navigation Jump to search
MediaWiki extensions manual
Crystal Clear action run.svg
DateDiff
Release status: stable
Implementation Parser function
Description Takes two dates and returns all intermediary days.
Author(s) Kwisatz,
Jeroen De Dauw
Latest version 0.3.1 (2016-10-29)
MediaWiki 1.23+
PHP 5.3+
Database changes No
License Creative Commons Attribution Share Alike 3.0
Download
README
CHANGELOG
Example sandbox.semantic-mediawiki.org
Hooks used
ParserFirstCallInit
Translate the DateDiff extension if it is available at translatewiki.net
Check usage and version matrix.

The DateDiff extension adds the #dates parser function that returns a list of intermediary days.

Usage[edit]

The #dates parser function comes with two parameters |StartDate and |EndDate which is used as follows:

Syntax
{{#dates:|StartDate=2016/10/01 |EndDate=2016/10/02 }}
Result

2016-10-01T00:00:00+02:00,2016-10-02T00:00:00+02:00

Examples[edit]

A typical use case are events in a semantic setup that span multiple days. In order to have the events appear on all days on a calendar provided by the Semantic Result Formats extension, you would use something like (requires the ParserFunctions extension):

{{#ifeq: {{{recurring}}} |no |{{#set: Has date={{#dates:|StartDate={{{from}}} |EndDate={{{till}}} }} |+sep=, }} }}

Number of days between two days (requires the Arrays extension):

{{#arraydefine:days|{{#dates:|StartDate=2015-04-01 |EndDate=2015-04-10 }} }}
{{#arraysize:days}}

Installation[edit]

  • Download and place the file(s) in a directory called DateDiff in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php:
    require_once "$IP/extensions/DateDiff/DateDiff.php";
    
  • Yes Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.