Difference between revisions of "Template:Coord/link"

From Chevy Wiki
Jump to navigation Jump to search
(Importing image file)
 
m (1 revision)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Documentation subpage}}
<span class="plainlinksneverexpand">[{{Coor URL}}{{{param}}}{{#if:{{{name|}}}|&title={{urlencode:{{{name}}}}}}} <span class="{{#ifeq:{{{default|}}}|dec|geo-nondefault|geo-default}}"><span class="geo-dms" title="Maps, aerial photos, and other data for {{{dms-lat}}} {{{dms-long}}}"><span class="latitude">{{{dms-lat}}}</span> <span class="longitude">{{{dms-long}}}</span></span></span><span class="geo-multi-punct"> / </span><span class="{{#ifeq:{{{default|}}}|dec|geo-default|geo-nondefault}}">{{#if:{{{name|}}}|<span class="vcard">|}}<span class="geo-dec geo" title="Maps, aerial photos, and other data for {{{dec-lat}}} {{{dec-long}}}">{{{dec-lat-display|{{#ifexpr:{{{dec-lat}}}<0|{{Coord/negzeropad|{{{dec-lat}}}|{{#expr:abs{{{dec-lat}}}}}}}°S|{{{dec-lat}}}°N}}}}} {{{dec-long-display|{{#ifexpr:{{{dec-long}}}<0|{{Coord/negzeropad|{{{dec-long}}}|{{#expr:abs{{{dec-long}}}}}}}°W|{{{dec-long}}}°E}}}}}</span><span style="display:none"> / <span class="geo">{{{dec-lat}}}; {{{dec-long}}}</span></span>{{#if:{{{name|}}}|<span style="display:none"> (<span class="fn org">{{{name|}}}</span>)</span></span>|}}</span>]</span><noinclude>{{pp-template|small=yes}}{{documentation}}[[Category:Coord template]]</noinclude>
<!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE -->
 
=== Description ===
----
This template converts a date to one of the standard date formats used on the English Wikipedia. This template is probably best used as an way of standardize the appearance of all dates in an article, including those in [[Wikipedia:Citation templates|citation templates]] and infoboxes.
 
'''''Do not'' [[Help:Substitution|subst]] this template''' in an attempt to obtain a permanent link to today's date, it will not work.  Instead, use '''{{tlx|today|subst=yes}}'''
 
=== Syntax ===
----
This template takes up to two parameters, both of which are optional:
 
<code><nowiki>{{</nowiki>date|</code><span style="color:gray;">''<date to be formatted>''</span>|<span style="color:gray;">''<date formatting style>''</span><code><nowiki>}}</nowiki></code>
 
* '''''<date to be formatted>''''' is an (optional) date to be formatted.
*: If no date is specified, the template emits the current date.<br />For example, {{nowrap|<tt><nowiki>{{date}}</nowiki></tt>}} produces {{date}}.
*:If a date is provided, but is not recognized as one, the text is just returned ''as is''. Most dates will however be recognized as such, including all the formats typically used on Wikipedia. Numerous variations thereof are also supported, including abbreviated or lower case month names; genitive 'st', 'nd', 'rd', 'th'; extraneous white space; missing comma etc.
*:'''Notes''':
*:* Some dates are converted even if they are not real dates, and some dates are not converted even though they are real dates. See [[#Known issues|known issues]] below.
*:* Only dates within the range {{date|January 1, 1000}} and {{date|December 31, 9999}} are supported. Dates with two digit dates will have unexpected results. Other dates outside the range 1000&ndash;9999 will be treated as if the second parameter were "none".
 
* '''''<date formatting style>''''' controls the date format in which the result is to be emitted.
*: If no style is specified, the template emits a date in 'd month yyyy' format, as it appears (for example) on discussion pages.
*:Recognized values for the second parameter are:
*:* '''<tt style="padding-right:2.5em;">none</tt>''' applies no formatting whatsoever
*:* '''<tt style="padding-right:3em;">dmy</tt>''' gives ''d mmmm yyyy'' (eg ''{{date||dmy}}''). This is the default format.
*:* '''<tt style="padding-right:3em;">mdy</tt>''' gives ''mmmm d, yyyy'' (eg ''{{date||mdy}}'')
*:* '''<tt style="padding-right:3em;">ymd</tt>''' gives ''yyyy mmmm dd'' (eg ''{{date||ymd}}'')
*:* '''<tt style="padding-right:3em;">iso</tt>''' gives an [[ISO 8601]] ''yyyy-mm-dd'' (eg ''{{date||iso}}'')
*:Prefixing these parameters with "<tt>l</tt>" (<tt>l</tt> for '''<tt>l</tt>'''ink) produces a linked date:
*:* '''<tt  style="padding-right:2em;">ldmy</tt>''' gives ''<nowiki>[[d mmmm]] [[yyyy]]</nowiki>'' (eg ''{{date||ldmy}}'')
*:* '''<tt style="padding-right:2em;">lmdy</tt>''' gives ''<nowiki>[[mmmm d]], [[yyyy]]</nowiki>'' (eg ''{{date||lmdy}}'')
*:* '''<tt style="padding-right:2em;">lymd</tt>''' gives ''<nowiki>[[yyyy]] [[mmmm dd]]</nowiki>'' (eg ''{{date||lymd}}'')
*:* '''<tt style="padding-right:2em;">liso</tt>''' gives ''<nowiki>[[yyyy]]-[[mm-dd]]</nowiki>'' (eg ''{{date||liso}}'')
*:'''Notes''':
*:* Although these are the four formats supported by MediaWiki's date autoformatting mechanism, only <code>dmy</code>/<code>ldmy</code> and <code>mdy</code>/<code>lmdy</code> are in accordance with the English language Wikipedia's [[MOS:DATE#Full_date_formatting|Manual of Style]]. The use of <code>iso</code>/<code>liso</code> ([[ISO 8601]]) format ''within article prose'' is expressly discouraged by the Manual of Style; this format should only be used in tables or lists.
*:* In each case, the result is exactly the same as what would be emitted by MediaWiki's date autoformatting mechanism.<div>However, dates are '''''not''''' manipulated by MediaWiki's date autoformatting mechanism even when linked. This permits dates to have a consistent appearance regardless of whether they are linked or not.</div>
 
=== Examples ===
----
 
==== With acceptable input ====
{| class="wikitable" style="width:80%; margin:0 10%"
!style="width:50%;"| Input
!style="width:50%;"| Output
|-
!colspan=2|No format specified
|-
|<tt><nowiki>{{date|2006-05-04}}</nowiki></tt>
|{{date|2006-05-04}}
|-
|<tt><nowiki>{{date|May 4, 2006}}</nowiki></tt>
|{{date|May 4, 2006}}
|-
|<tt><nowiki>{{date|4 May 2006}}</nowiki></tt>
|{{date|4 May 2006}}
|-
|<tt><nowiki>{{date|4 May}}</nowiki></tt>
|{{date|4 May}}
|-
|<tt><nowiki>{{date|May 4}}</nowiki></tt>
|{{date|May 4}}
|-
!colspan=2|''dmy'' format
|-
|<tt><nowiki>{{date|2006-05-04|dmy}}</nowiki></tt>
|{{date|2006-05-04|dmy}}
|-
|<tt><nowiki>{{date|May 4, 2006|dmy}}</nowiki></tt>
|{{date|May 4, 2006|dmy}}
|-
|<tt><nowiki>{{date|4 May 2006|dmy}}</nowiki></tt>
|{{date|4 May 2006|dmy}}
|-
|<tt><nowiki>{{date|4 May|dmy}}</nowiki></tt>
|{{date|4 May|dmy}}
|-
|<tt><nowiki>{{date|May 4|dmy}}</nowiki></tt>
|{{date|May 4|dmy}}
|-
!colspan=2|''mdy'' format
|-
|<tt><nowiki>{{date|2006-05-04|mdy}}</nowiki></tt>
|{{date|2006-05-04|mdy}}
|-
|<tt><nowiki>{{date|May 4, 2006|mdy}}</nowiki></tt>
|{{date|May 4, 2006|mdy}}
|-
|<tt><nowiki>{{date|4 May 2006|mdy}}</nowiki></tt>
|{{date|4 May 2006|mdy}}
|-
|<tt><nowiki>{{date|4 May|mdy}}</nowiki></tt>
|{{date|4 May|mdy}}
|-
|<tt><nowiki>{{date|May 4|mdy}}</nowiki></tt>
|{{date|May 4|mdy}}
|-
!colspan=2|''ymd'' format
|-
|<tt><nowiki>{{date|2006-05-04|ymd}}</nowiki></tt>
|{{date|2006-05-04|ymd}}
|-
|<tt><nowiki>{{date|May 4, 2006|ymd}}</nowiki></tt>
|{{date|May 4, 2006|ymd}}
|-
|<tt><nowiki>{{date|4 May 2006|ymd}}</nowiki></tt>
|{{date|4 May 2006|ymd}}
|-
|<tt><nowiki>{{date|4 May|ymd}}</nowiki></tt>
|{{date|4 May|ymd}}
|-
|<tt><nowiki>{{date|May 4|ymd}}</nowiki></tt>
|{{date|May 4|ymd}}
|-
!colspan=2|''iso'' format
|-
|<tt><nowiki>{{date|2006-05-04|iso}}</nowiki></tt>
|{{date|2006-05-04|iso}}
|-
|<tt><nowiki>{{date|May 4, 2006|iso}}</nowiki></tt>
|{{date|May 4, 2006|iso}}
|-
|<tt><nowiki>{{date|4 May 2006|iso}}</nowiki></tt>
|{{date|4 May 2006|iso}}
|-
|<tt><nowiki>{{date|4 May|iso}}</nowiki></tt>
|{{date|4 May|iso}}
|-
|<tt><nowiki>{{date|May 4|iso}}</nowiki></tt>
|{{date|May 4|iso}}
|-
!colspan=2|''none'' format
|-
|<tt><nowiki>{{date|2006-05-04|none}}</nowiki></tt>
|{{date|2006-05-04|none}}
|-
|<tt><nowiki>{{date|May 4, 2006|none}}</nowiki></tt>
|{{date|May 4, 2006|none}}
|-
|<tt><nowiki>{{date|4 May 2006|none}}</nowiki></tt>
|{{date|4 May 2006|none}}
|-
|<tt><nowiki>{{date|4 May|none}}</nowiki></tt>
|{{date|4 May|none}}
|-
|<tt><nowiki>{{date|May 4|none}}</nowiki></tt>
|{{date|May 4|none}}
|}
 
==== Other valid input ====
 
A wide variety of other input formats are handled correctly by the template:
 
{| class="wikitable" style="width:80%; margin:0 10%"
!style="width:50%;"| Input
!style="width:50%;"| Output
|-
|<tt><nowiki>{{date|1st December 2008}}</nowiki></tt> ([[Genitive case|genitive]] 'st')
|{{date|1st December 2008}}
|-
|<tt><nowiki>{{date|June 24 2006}}</nowiki></tt> (missing comma)
|{{date|june 24 2006}}
|-
|<tt><nowiki>{{date|24 june 2006}}</nowiki></tt> (lowercase month name)
|{{date|24 june 2006}}
|-
|<tt><nowiki>{{date|24 jun}}</nowiki></tt> (abbreviated month name)
|{{date|24 jun}}
|-
|<tt><nowiki>{{date|June 2006}}</nowiki></tt>
|{{date|June 2006}}
|}
 
==== Invalid input ====
 
Input strings that the template cannot format are returned unaltered.  This includes strings containing characters such as square brackets, so any links will result in unformatted output.
 
{| class="wikitable" style="width:80%; margin:0 10%"
!style="width:50%;"| Input
!style="width:50%;"| Output
|-
|<tt><nowiki>{{date|23007-031-24}}</nowiki></tt>
|{{date|23007-031-24}}
|-
|<tt><nowiki>{{date|[[1 December]] [[2008]]|ymd}}</nowiki></tt>
|{{date|[[1 December]] [[2008]]|ymd}}
|-
|<tt><nowiki>{{date|1 December [[2008 in film|2008]]|mdy}}</nowiki></tt>
|{{date|1 December [[2008 in film|2008]]|mdy}}
|}
 
----
=== Known issues ===
 
; Out-of-range values are "fixed"
* The [[PHP]] library that this template ultimately depends on converts out-of-range values to the next-best in-range values. As a result, some date-like values that are not actually valid dates get converted anyway. These include...
** all dates with zero day-of-the-month. Such a "zero-th" day of a month gets converted into the last day of the previous month.<div>For example, <code><nowiki>{{date|June 0, 2006}}</nowiki></code> results in <code>{{date|June 0, 2006}}</code>.</div><div>Similarly, <code><nowiki>{{date|0 January 2006}}</nowiki></code> becomes <code>{{date|0 January 2006}}</code>.</div>
** all dates with day-number values that exceed the number of days in the specified month cause the date to be incremented into the next month.<div>For example, <code><nowiki>{{date|31 November 2008}}</nowiki></code> results in <code>{{date|31 November 2008}}</code>, since November has only 30 days.</div><div>Similarly, <code><nowiki>{{date|February 29, 2007}}</nowiki></code> results in <code>{{date|February 29, 2007}}</code>, since 2007 was not a leap year.</div><div><small>Note: Due to a parser peculiarity in the PHP library, 'December 32' and '32 December' are treated differently, and the latter results in an error (which causes this template to emit it unchanged), and only the former "overflows" into the next month.</small></div>
 
; Non-Gregorian dates are treated as Gregorian
* The PHP library that this template ultimately depends on assumes that all dates, irrespective of context, are [[Gregorian calendar]] dates. Consequently,...
** some dates that would be valid in a non-Gregorian context are treated as out-of-range dates and converted to the next-best in-range values. For example, <code><nowiki>{{date|30 February 1712}}</nowiki></code> results in <code>{{date|30 February 1712}}</code> because &ndash; even though 30 February 1712 is a valid date in the Swedish calendar &ndash; February 1712 had only 29 days in the Gregorian calendar.
** ten dates are not reformatted. These are 29 February & 1 March of the years 1000, 1100, 1300, 1400, 1500. The cause of this is the same as that of the Swedish 30 February 1712.
** some dates that would not be valid in some contexts are converted normally. For example, 29 February 1912 or 1 February 1918 are not valid in a Russian context, but perfectly valid in the Gregorian one.
 
; ISO 8601 format not suitable for years before 1583
The ISO 8601 standard requires mutual agreement between those using the format to use years earlier than 1583. Since no agreement has been obtained from our readers, that format should not be used for such years, nor for any date not in the Gregorian calendar.
 
; Not suitable for use in Microformats
* [[hCalendar]] and [[hCard]] [[microformat]]s have various date properties, which are not emitted by this template. Until that is resolved, use {{Tl|Start date}}, {{Tl|End date}}, {{Tl|Birth date}} or one of their variants, as necessary, in infoboxes which require microformat-compatible date templates.
 
<includeonly>
<!-- CATEGORIES AND INTERWIKIS HERE, THANKS -->
[[Category:Date-computing templates]]
[[Category:ISO date templates]]
 
[[ja:Template:Date]]
[[no:Mal:ISOtilNorskdato]]
[[pt:Predefinição:Data]]
</includeonly>

Latest revision as of 04:45, 6 February 2009

{{{dms-lat}}} {{{dms-long}}} / Expression error: Unrecognized punctuation character "{". Expression error: Unrecognized punctuation character "{". / {{{dec-lat}}}; {{{dec-long}}}

[edit] Template-info.svg Template documentation

This template, {{Coord/link}}, is used by {{Coord}}.

Examples

{{coord|10|N|30|W}}10°N 30°W / 10°N 30°W / 10; 30
{{coord|10|11|N|30|31|W}}10°11′N 30°31′W / 10.183°N 30.517°W / 10.183; -30.517
{{coord|10|11|12|N|30|31|32|W}}10°11′12″N 30°31′32″W / 10.18667°N 30.52556°W / 10.18667; -30.52556

Notes on classes

Note: the span classes "geo-default", "geo-dec", and "geo-dms" are defined at http://en.wikipedia.org/wiki/MediaWiki:Common.css.

In addition, "geo" and the nested "latitude" and "longitude" have special meaning as a Geo microformat and so might also be used by other templates; see also http://microformats.org/wiki/geo.

Display

By default coordinates are displayed in the format in which they are specified.

To always display coordinates as DMS values, add this to your monobook.css:

.geo-default { display: inline }
.geo-nondefault { display: inline }
.geo-dec { display: none }
.geo-dms { display: inline }

To always display coordinates as decimal values, add this to your monobook.css:

.geo-default { display: inline }
.geo-nondefault { display: inline }
.geo-dec { display: inline }
.geo-dms { display: none }

To display coordinates in both formats, add this to your monobook.css:

.geo-default { display: inline }
.geo-nondefault { display: inline }
.geo-dec { display: inline }
.geo-dms { display: inline }
.geo-multi-punct { display: inline }

If CSS is disabled, or you have an old copy of MediaWiki:Common.css cached, you will see both formats. (You can either clear your cache or manually refresh this URL: [1].)

To disable display of the blue globe adjacent to coordinates, add this to your monobook.js

var wma_settings = {enabled:false}

Note that this will disable WikiMiniAtlas

See also Wikipedia:Manual of Style (dates and numbers)#Geographical coordinates.


ca:Plantilla:Coord/link ja:Template:Coord/link pl:Szablon:Koordynaty/Linkuj sl:Predloga:Koord/povezava