Module:Citation/CS1: Difference between revisions

    m>Trappist the monk
    (Synch from sandbox;)
    m>Trappist the monk
    (Fix undocumented arxiv error check bug;)
    Line 260: Line 260:
    format and error check arXiv identifier.  There are two valid forms of the identifier:
    format and error check arXiv identifier.  There are two valid forms of the identifier:
    the first form, valid only between date codes 9108 and 0703 is:
    the first form, valid only between date codes 9108 and 0703 is:
    arXiv:<archive>.<class>/<date code><number>
    arXiv:<archive>.<class>/<date code><number><version>
    where:
    where:
    <archive> is a string of alpha characters - may be hyphenated; no other punctuation
    <archive> is a string of alpha characters - may be hyphenated; no other punctuation
    Line 267: Line 267:
    first digit of YY for this form can only 9 and 0
    first digit of YY for this form can only 9 and 0
    <number> is a three-digit number
    <number> is a three-digit number
    <version> is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
    the second form, valid from April 2007 is:
    the second form, valid from April 2007 is:
    Line 281: Line 282:
    local err_cat = ""
    local err_cat = ""
    year, month = id:match("^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d$"); -- test for the 9108-0703 format
    year, month, version = id:match("^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d([v%d]*)$"); -- test for the 9108-0703 format
    if not year then -- arXiv id is not proper 9108-0703 form
    if not year then -- arXiv id is not proper 9108-0703 form
    year, month, version = id:match("^(%d%d)([01]%d)%.%d%d%d%d([v%d]*)$"); -- test for the 0704- format
    year, month, version = id:match("^(%d%d)([01]%d)%.%d%d%d%d([v%d]*)$"); -- test for the 0704- format
    Line 299: Line 300:
    month = tonumber(month);
    month = tonumber(month);
    if ((91 > year and 7 < year) or (1 > month and 12 < month)) or -- if invalid year or invalid month
    if ((91 > year and 7 < year) or (1 > month and 12 < month)) or -- if invalid year or invalid month
    ((91 == year and 8 > month) or (7 == year and 3 < month)) then -- if years ok, are starting and ending months ok?
    ((91 == year and 8 > month) or (7 == year and 3 < month)) or -- if years ok, are starting and ending months ok?
    err_cat = ' ' .. seterror( 'bad_arxiv' ); -- set error message
    is_set (version) and nil == version:match("v%d+") then -- is version proper format of single 'v' followed by digits?
    err_cat = ' ' .. seterror( 'bad_arxiv' ); -- set error message
    end
    end
    end
    end