Extension:DateDiff
DateDiff Release status: stable |
|
---|---|
Implementation | Parser function |
Description | Takes two dates and returns all intermediary days |
Author(s) |
|
Latest version | 0.4.0 (2021-11-11) |
MediaWiki | 1.25+ |
PHP | 7.2+ |
Database changes | No |
License | Creative Commons Attribution Share Alike 3.0 |
Download | README CHANGELOG |
Example | sandbox.semantic-mediawiki.org |
Quarterly downloads | 1 (Ranked 139th) |
Translate the DateDiff extension if it is available at translatewiki.net | |
The DateDiff extension adds the #dates
parser function that returns a list of intermediary days.
Usage
editThe #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
editA typical use case is events in a semantic setup that span multiple days. 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 move the extracted
DateDiff
folder to yourextensions/
directory.
Developers and code contributors should install the extension from Git instead, using:cd extensions/
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/DateDiff - Add the following code at the bottom of your LocalSettings.php file:
wfLoadExtension( 'DateDiff' );
- Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.
To users running MediaWiki 1.39 or earlier:
The instructions above describe the new way of installing this extension using wfLoadExtension()
.
If you need to install this extension on these earlier versions (MediaWiki 1.39 and earlier), instead of wfLoadExtension( 'DateDiff' );
, you need to use:
require_once "$IP/extensions/DateDiff/DateDiff.php";
This extension is included in the following wiki farms/hosts and/or packages: This is not an authoritative list. Some wiki farms/hosts and/or packages may contain this extension even if they are not listed here. Always check with your wiki farms/hosts or bundle to confirm. |