Jump to content
 







Main menu
   


Navigation  



Main page
Contents
Current events
Random article
About Wikipedia
Contact us
Donate
 




Contribute  



Help
Learn to edit
Community portal
Recent changes
Upload file
 








Search  

































Create account

Log in
 









Create account
 Log in
 




Pages for logged out editors learn more  



Contributions
Talk
 



















Contents

   



(Top)
 


1 Syntax  





2 Example  





3 Data  





4 See also  














Module:British regnal year






العربية
Авар
تۆرکجه
Basa Bali

Буряад
Cebuano
الدارجة
فارسی
ि
Bahasa Indonesia

Македонски


 / Mìng-dĕ̤ng-nḡ
ି
Oʻzbekcha / ўзбекча


Scots

Simple English
کوردی
Svenska
ி

اردو
Tiếng Vit

 

Edit links
 









Module
Talk
 

















Read
View source
View history
 








Tools
   


Actions  



Read
View source
View history
 




General  



What links here
Related changes
Upload file
Special pages
Permanent link
Page information
Get shortened URL
Download QR code
Wikidata item
 




Print/export  



Download as PDF
Printable version
 
















Appearance
   

 





Permanently protected module

From Wikipedia, the free encyclopedia
 


This module implements the {{British regnal year}} template. It converts a year in the Gregorian calendar into a British regnal year.

Syntax

{{#invoke:British regnal year|main|<year in Gregorian calendar>}}

Example

{{British regnal year|1952}} → 16 Geo. 6 – 1 Eliz. 2

Data

The data for the module is stored in a table at Module:British regnal year/data. The module looks through the data list from newest to oldest, and returns the data for the first result where the input year is greater than or equal to the year value. The data table entries are organised as follows:

See also

-- This module implements {{British regnal year}}. It converts a year in the Gregorian
-- calendar to the equivalent English or British regnal year.

local data = mw.loadData( 'Module:British regnal year/data' )

local p = {}

function p.main( frame )
    -- If we are being called from #invoke, then the year is the first positional
    -- argument. If not, it is the frame parameter.
    local inputYear
    if frame == mw.getCurrentFrame() then
        inputYear = frame:getParent().args[ 1 ]
        local frameArgsYear = frame.args[ 1 ]
        if frameArgsYear then
            inputYear = frameArgsYear
        end
    else
        inputYear = frame
    end

    -- Convert the input to an integer if possible. Return "N/A" if the input could
    -- not be converted, or if the converted input is too big or too small.
    if type( inputYear ) ~= 'number' then
        inputYear = tonumber( inputYear )
    end
    if not inputYear then
        return "''N/A''"
    end
    local currentYear = tonumber( mw.language.getContentLanguage():formatDate( 'Y' ) )
    -- The year 1066 is significant because it is when the Norman conquest of England occurred.
    if inputYear < 1066 or inputYear > currentYear then
        return "''N/A''"
    end
    
    -- Find the year in the data page and display the output.
    for _, t in ipairs( data ) do
        local dataYear = t.year
        if inputYear >= dataYear then
            -- Get data values from the data page.
            local startYear = t.startYear
            local currentRegnalYear = inputYear - dataYear + startYear
            local linkCurrent = t.linkCurrent
            local prevEndYear = t.prevEndYear
            local linkPrev = t.linkPrev
            local note = t.note

            if inputYear > dataYear then
                -- Years with the same monarch.
                return mw.ustring.format(
                    '%d&nbsp;%s&nbsp;–&nbsp;%d&nbsp;%s%s',
                    currentRegnalYear - 1, linkCurrent, currentRegnalYear, linkCurrent, note or ''
                )
            elseif inputYear == dataYear and prevEndYear and linkPrev then
                -- Years with a different monarch.
                return mw.ustring.format(
                    '%d&nbsp;%s&nbsp;–&nbsp;%d&nbsp;%s%s',
                    prevEndYear, linkPrev, currentRegnalYear, linkCurrent, note or ''
                )
            else
                -- This should only match the year 1066.
                return mw.ustring.format(
                    '%d&nbsp;%s%s',
                    currentRegnalYear, linkCurrent, note or ''
                )
            end
        end
    end
end

return p

Retrieved from "https://en.wikipedia.org/w/index.php?title=Module:British_regnal_year&oldid=1177868771"

Category: 
Modules in beta
Hidden category: 
Wikipedia template-protected modules
 



This page was last edited on 30 September 2023, at 03:29 (UTC).

Text is available under the Creative Commons Attribution-ShareAlike License 4.0; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy. Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc., a non-profit organization.



Privacy policy

About Wikipedia

Disclaimers

Contact Wikipedia

Code of Conduct

Developers

Statistics

Cookie statement

Mobile view



Wikimedia Foundation
Powered by MediaWiki