Extension:DateDiff

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manualManual:Extensions
Crystal Clear action run.png
DateDiff

Release status:Extension status stable

ImplementationTemplate:Extension#type Parser function
DescriptionTemplate:Extension#description Takes two dates and returns all intermediary days.
Author(s)Template:Extension#username Kwisatz,
Jeroen De Dauw
Latest versionTemplate:Extension#version 0.3.1 (2016-10-29)
MediaWikiTemplate:Extension#mediawiki 1.23+
PHPTemplate:Extension#php 5.3+
Database changesTemplate:Extension#needs-updatephp No
LicenseTemplate:Extension#license Creative Commons Attribution Share Alike 3.0
Download
README
CHANGELOG
Hooks usedTemplate:Extension#hook
ParserFirstCallInitManual:Hooks/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:

{{#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";
  • YesY Done - Navigate to Special:Version on your wiki to verify that the extension is successfully installed.