This module contains routines that support the Citation Style 1 and Citation Style 2 date formats for citations on Wikipedia. In particular, this module contains a suite of functions that validate date formats and content for the variety of date-holding parameters associated with cs1|2 citations.
These files comprise the module support for cs1|2 citation templates:
live | sandbox | description | |
---|---|---|---|
![]() | Module:Citation/CS1 | Module:Citation/CS1/sandbox | Rendering and support functions |
Module:Citation/CS1/Configuration | Module:Citation/CS1/Configuration/sandbox | Translation tables; error and identifier handlers | |
Module:Citation/CS1/Whitelist | Module:Citation/CS1/Whitelist/sandbox | List of active, deprecated, and obsolete CS1 parameters | |
Module:Citation/CS1/Date validation | Module:Citation/CS1/Date validation/sandbox | Date format validation functions | |
![]() | Module:Citation/CS1/Suggestions | Module:Citation/CS1/Suggestions/sandbox | List that maps common erroneous parameter names to valid parameter names |
localp={}--[[--------------------------< I S _ V A L I D _ A C C E S S D A T E >----------------------------------------returns true if: Wikipedia start date <= accessdate < today + 2 daysWikipedia start date is 2001-01-15T00:00:00 UTC which is 979516800 seconds after 1970-01-01T00:00:00 UTC (the start of Unix time)accessdate is the date provided in |accessdate= at time 00:00:00 UTCtoday is the current date at time 00:00:00 UTC plus 48 hours if today is 2015-01-01T00:00:00 then adding 24 hours gives 2015-01-02T00:00:00 – one second more than today adding 24 hours gives 2015-01-03T00:00:00 – one second more than tomorrow]]localfunctionis_valid_accessdate(accessdate)locallang=mw.getContentLanguage();localgood1,good2;localaccess_ts,tomorrow_ts;-- to hold unix time stamps representing the datesgood1,access_ts=pcall(lang.formatDate,lang,'U',accessdate);-- convert accessdate value to unix timesatmp good2,tomorrow_ts=pcall(lang.formatDate,lang,'U','today + 2 days');-- today midnight + 2 days is one second more than all day tomorrowifgood1andgood2thenaccess_ts=tonumber(access_ts);-- convert to numbers for the comparisontomorrow_ts=tonumber(tomorrow_ts);elsereturnfalse;-- one or both failed to convert to unix time stampendif979516800<=access_tsandaccess_ts<tomorrow_tsthen-- Wikipedia start date <= accessdate < tomorrow's datereturntrue;elsereturnfalse;-- accessdate out of rangeendend--[[--------------------------< G E T _ M O N T H _ N U M B E R >----------------------------------------------returns a number according to the month in a date: 1 for January, etc. Capitalization and spelling must be correct. If not a valid month, returns 0]]localfunctionget_month_number(month)locallong_months={['January']=1,['February']=2,['March']=3,['April']=4,['May']=5,['June']=6,['July']=7,['August']=8,['September']=9,['October']=10,['November']=11,['December']=12};localshort_months={['Jan']=1,['Feb']=2,['Mar']=3,['Apr']=4,['May']=5,['Jun']=6,['Jul']=7,['Aug']=8,['Sep']=9,['Oct']=10,['Nov']=11,['Dec']=12};localtemp;temp=long_months[month];iftempthenreturntemp;end-- if month is the long-form nametemp=short_months[month];iftempthenreturntemp;end-- if month is the short-form namereturn0;-- misspelled, improper case, or not a month nameend--[[--------------------------< G E T _ S E A S O N _ N U M B E R >--------------------------------------------returns a number according to the sequence of seasons in a year: 1 for Winter, etc. Capitalization and spelling must be correct. If not a valid season, returns 0]]localfunctionget_season_number(season)localseason_list={['Winter']=1,['Spring']=2,['Summer']=3,['Fall']=4,['Autumn']=4}localtemp;temp=season_list[season];iftempthenreturntemp;end-- if season is a valid name return its numberreturn0;-- misspelled, improper case, or not a season nameend--[[--------------------------< I S _ P R O P E R _ N A M E >--------------------------------------------------returns a non-zero number if date contains a recognized proper name. Capitalization and spelling must be correct.]]localfunctionis_proper_name(name)localname_list={['Christmas']=1}localtemp;temp=name_list[name];iftempthenreturntemp;end-- if name is a valid name return its numberreturn0;-- misspelled, improper case, or not a proper nameend--[[--------------------------< I S _ V A L I D _ M O N T H _ O R _ S E A S O N >--------------------------------returns true if month or season is valid (properly spelled, capitalized, abbreviated)]]localfunctionis_valid_month_or_season(month_season)if0==get_month_number(month_season)then-- if month text isn't one of the twelve months, might be a seasonif0==get_season_number(month_season)then-- not a month, is it a season?returnfalse;-- return false not a month or one of the five seasonsendendreturntrue;end--[[--------------------------< I S _ V A L I D _ Y E A R >----------------------------------------------------Function gets current year from the server and compares it to year from a citation parameter. Years more than one year in the future are not acceptable.]]localfunctionis_valid_year(year)ifnotis_set(year_limit)thenyear_limit=tonumber(os.date("%Y"))+1;-- global variable so we only have to fetch it onceendreturntonumber(year)<=year_limit;-- false if year is in the future more than one yearend--[[Returns true if day is less than or equal to the number of days in month and year is no farther into the future than next year; else returns false.Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap years before 1582 and Gregorian leap years after 1582.Where the two calendars overlap (1582 to approximately 1923) dates are assumed to be Gregorian.]]localfunctionis_valid_date(year,month,day)localdays_in_month={31,28,31,30,31,30,31,31,30,31,30,31};localmonth_length;ifnotis_valid_year(year)then-- no farther into the future than next yearreturnfalse;endif(2==month)then-- if Februarymonth_length=28;-- then 28 days unlessif1582>tonumber(year)then-- Julian calendarif0==(year%4)thenmonth_length=29;endelse-- Gregorian calendarif(0==(year%4)and(0~=(year%100)or0==(year%400)))then-- is a leap year?month_length=29;-- if leap year then 29 days in Februaryendendelsemonth_length=days_in_month[month];endiftonumber(day)>month_lengththenreturnfalse;endreturntrue;end--[[--------------------------< I S _ V A L I D _ M O N T H _ R A N G E _ S T Y L E >--------------------------Months in a range are expected to have the same style: Jan–Mar or October–December but not February–Mar or Jul–August. There is a special test for May because it can be either short or long form.Returns true when style for both months is the same]]localfunctionis_valid_month_range_style(month1,month2)locallen1=month1:len();locallen2=month2:len();iflen1==len2thenreturntrue;-- both months are short form so return trueelseif'May'==month1or'May'==month2thenreturntrue;-- both months are long form so return trueelseif3==len1or3==len2thenreturnfalse;-- months are mixed form so return falseelsereturntrue;-- both months are long form so return trueendend--[[--------------------------< I S _ V A L I D _ M O N T H _ S E A S O N _ R A N G E >------------------------Check a pair of months or seasons to see if both are valid members of a month or season pair.Month pairs are expected to be left to right, earliest to latest in time.Similarly, seasons are also left to right, earliest to latest in time. There is an oddity with seasons: winter is assigned a value of 1, spring 2, ...,fall and autumn 4. Because winter can follow fall/autumn at the end of a calender year, a special test is made to see if |date=Fall-Winter yyyy (4-1) is the date.]]localfunctionis_valid_month_season_range(range_start,range_end)localrange_start_number=get_month_number(range_start);if0==range_start_numberthen-- is this a month range?localrange_start_number=get_season_number(range_start);-- not a month; is it a season? get start season numberlocalrange_end_number=get_season_number(range_end);-- get end season numberif0~=range_start_numberthen-- is start of range a season?ifrange_start_number<range_end_numberthen-- range_start is a seasonreturntrue;-- return true when range_end is also a season and follows start season; else falseendif4==range_start_numberand1==range_end_numberthen-- special case when range is Fall-Winter or Autumn-Winterreturntrue;endendreturnfalse;-- range_start is not a month or a season; or range_start is a season and range_end is not; or improper season sequenceendlocalrange_end_number=get_month_number(range_end);-- get end month numberifrange_start_number<range_end_numberthen-- range_start is a month; does range_start precede range_end?ifis_valid_month_range_style(range_start,range_end)then-- do months have the same style?returntrue;-- proper order and same styleendendreturnfalse;-- range_start month number is greater than or equal to range end number; or range end isn't a monthend--[[--------------------------< C H E C K _ D A T E >----------------------------------------------------------Check date format to see that it is one of the formats approved by WP:DATESNO or WP:DATERANGE. Exception: only allowed range separator is endash.Additionally, check the date to see that it is a real date: no 31 in 30-day months; no 29 February when not a leap year. Months, both long-form and threecharacter abbreviations, and seasons must be spelled correctly. Future years beyond next year are not allowed.If the date fails the format tests, this function returns false and does not return values for anchor_year and COinS_date. When this happens, the date parameter isused in the COinS metadata and the CITEREF identifier gets its year from the year parameter if present otherwise CITEREF does not get a date value.Inputs: date_string - date string from date-holding parameters (date, year, accessdate, embargo, archivedate, etc.)Returns: false if date string is not a real date; else true, anchor_year, COinS_date anchor_year can be used in CITEREF anchors COinS_date is date_string without anchor_year disambiguator if any]]localfunctioncheck_date(date_string)localyear;-- assume that year2, months, and days are not used;localyear2=0;-- second year in a year rangelocalmonth=0;localmonth2=0;-- second month in a month rangelocalday=0;localday2=0;-- second day in a day rangelocalanchor_year;localcoins_date;ifdate_string:match("^%d%d%d%d%-%d%d%-%d%d$")then-- year-initial numerical year month day formatyear,month,day=string.match(date_string,"(%d%d%d%d)%-(%d%d)%-(%d%d)");month=tonumber(month);if12<monthor1>monthor1583>tonumber(year)thenreturnfalse;end-- month number not valid or not Gregorian calendaranchor_year=year;elseifdate_string:match("^%a+ +[1-9]%d?, +[1-9]%d%d%d%a?$")then-- month-initial: month day, yearmonth,day,anchor_year,year=string.match(date_string,"(%a+)%s*(%d%d?),%s*((%d%d%d%d)%a?)");month=get_month_number(month);if0==monththenreturnfalse;end-- return false if month text isn't one of the twelve monthselseifdate_string:match("^%a+ +[1-9]%d?–[1-9]%d?, +[1-9]%d%d%d%a?$")then-- month-initial day range: month day–day, year; days are separated by endashmonth,day,day2,anchor_year,year=string.match(date_string,"(%a+) +(%d%d?)–(%d%d?), +((%d%d%d%d)%a?)");iftonumber(day)>=tonumber(day2)thenreturnfalse;end-- date range order is left to right: earlier to later; dates may not be the same;month=get_month_number(month);if0==monththenreturnfalse;end-- return false if month text isn't one of the twelve monthselseifdate_string:match("^[1-9]%d? +%a+ +[1-9]%d%d%d%a?$")then-- day-initial: day month yearday,month,anchor_year,year=string.match(date_string,"(%d%d*)%s*(%a+)%s*((%d%d%d%d)%a?)");month=get_month_number(month);if0==monththenreturnfalse;end-- return false if month text isn't one of the twelve monthselseifdate_string:match("^[1-9]%d?–[1-9]%d? +%a+ +[1-9]%d%d%d%a?$")then-- day-range-initial: day–day month year; days are separated by endashday,day2,month,anchor_year,year=string.match(date_string,"(%d%d?)–(%d%d?) +(%a+) +((%d%d%d%d)%a?)");iftonumber(day)>=tonumber(day2)thenreturnfalse;end-- date range order is left to right: earlier to later; dates may not be the same;month=get_month_number(month);if0==monththenreturnfalse;end-- return false if month text isn't one of the twelve monthselseifdate_string:match("^[1-9]%d? +%a+ – [1-9]%d? +%a+ +[1-9]%d%d%d%a?$")then-- day initial month-day-range: day month - day month year; uses spaced endashday,month,day2,month2,anchor_year,year=date_string:match("(%d%d?) +(%a+) – (%d%d?) +(%a+) +((%d%d%d%d)%a?)");if(notis_valid_month_season_range(month,month2))ornotis_valid_year(year)thenreturnfalse;end-- date range order is left to right: earlier to later;month=get_month_number(month);month2=get_month_number(month2);elseifdate_string:match("^%a+ +[1-9]%d? – %a+ +[1-9]%d?, +[1-9]%d%d%d?%a?$")then-- month initial month-day-range: month day – month day, year; uses spaced endashmonth,day,month2,day2,anchor_year,year=date_string:match("(%a+) +(%d%d?) – (%a+) +(%d%d?), +((%d%d%d%d)%a?)");if(notis_valid_month_season_range(month,month2))ornotis_valid_year(year)thenreturnfalse;endmonth=get_month_number(month);month2=get_month_number(month2);elseifdate_string:match("^[1-9]%d? +%a+ +[1-9]%d%d%d – [1-9]%d? +%a+ +[1-9]%d%d%d%a?$")then-- day initial month-day-year-range: day month year - day month year; uses spaced endashday,month,year,day2,month2,anchor_year,year2=date_string:match("(%d%d?) +(%a+) +(%d%d%d%d?) – (%d%d?) +(%a+) +((%d%d%d%d?)%a?)");iftonumber(year2)<=tonumber(year)thenreturnfalse;end-- must be sequential years, left to right, earlier to laterifnotis_valid_year(year2)ornotis_valid_month_range_style(month,month2)thenreturnfalse;end-- year2 no more than one year in the future; months same stylemonth=get_month_number(month);month2=get_month_number(month2);elseifdate_string:match("^%a+ +[1-9]%d?, +[1-9]%d%d%d – %a+ +[1-9]%d?, +[1-9]%d%d%d%a?$")then-- month initial month-day-year-range: month day, year – month day, year; uses spaced endashmonth,day,year,month2,day2,anchor_year,year2=date_string:match("(%a+) +(%d%d?), +(%d%d%d%d) – (%a+) +(%d%d?), +((%d%d%d%d)%a?)");iftonumber(year2)<=tonumber(year)thenreturnfalse;end-- must be sequential years, left to right, earlier to laterifnotis_valid_year(year2)ornotis_valid_month_range_style(month,month2)thenreturnfalse;end-- year2 no more than one year in the future; months same stylemonth=get_month_number(month);month2=get_month_number(month2);elseifdate_string:match("^%a+ +[1-9]%d%d%d–%d%d%a?$")then-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endashifnil==date_string:match("^Winter")andnil==date_string:match("^Summer")thenreturnfalseend;-- 'month' can only be Winter or Summerlocalcentury;year,century,anchor_year,year2=date_string:match("%a+ +((%d%d)%d%d)–((%d%d)%a?)");anchor_year=year..'–'..anchor_year;-- assemble anchor_year from both yearsyear2=century..year2;-- add the century to year2 for comparisonsif1~=tonumber(year2)-tonumber(year)thenreturnfalse;end-- must be sequential years, left to right, earlier to laterifnotis_valid_year(year2)thenreturnfalse;end-- no year farther in the future than next yearelseifdate_string:match("^%a+ +[1-9]%d%d%d–[1-9]%d%d%d%a?$")then-- special case Winter/Summer year-year; year separated with unspaced endashifnil==date_string:match("^Winter")andnil==date_string:match("^Summer")thenreturnfalseend;-- 'month' can only be Winter or Summeryear,anchor_year,year2=date_string:match("%a+ +(%d%d%d%d)–((%d%d%d%d)%a?)");anchor_year=year..'–'..anchor_year;-- assemble anchor_year from both yearsif1~=tonumber(year2)-tonumber(year)thenreturnfalse;end-- must be sequential years, left to right, earlier to laterifnotis_valid_year(year2)thenreturnfalse;end-- no year farther in the future than next yearelseifdate_string:match("^%a+ +[1-9]%d%d%d% – %a+ +[1-9]%d%d%d%a?$")then-- month/season year - month/season year; separated by spaced endashmonth,year,month2,anchor_year,year2=date_string:match("(%a+) +(%d%d%d%d) – (%a+) +((%d%d%d%d)%a?)");anchor_year=year..'–'..anchor_year;-- assemble anchor_year from both yearsiftonumber(year)>=tonumber(year2)thenreturnfalse;end-- left to right, earlier to later, not the sameifnotis_valid_year(year2)thenreturnfalse;end-- no year farther in the future than next yearifnot((0~=get_month_number(month)and0~=get_month_number(month2)andis_valid_month_range_style(month,month2))or-- both must be month year, same month style(0~=get_season_number(month)and0~=get_season_number(month2)))thenreturnfalse;end-- or season year, not mixedelseifdate_string:match("^%a+–%a+ +[1-9]%d%d%d%a?$")then-- month/season range year; months separated by endash month,month2,anchor_year,year=date_string:match("(%a+)–(%a+)%s*((%d%d%d%d)%a?)");if(notis_valid_month_season_range(month,month2))or(notis_valid_year(year))thenreturnfalse;endelseifdate_string:match("^%a+ +%d%d%d%d%a?$")then-- month/season year or proper-name yearmonth,anchor_year,year=date_string:match("(%a+)%s*((%d%d%d%d)%a?)");ifnotis_valid_year(year)thenreturnfalse;endifnotis_valid_month_or_season(month)and0==is_proper_name(month)thenreturnfalse;endelseifdate_string:match("^[1-9]%d%d%d?–[1-9]%d%d%d?%a?$")then-- Year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999year,anchor_year,year2=date_string:match("(%d%d%d%d?)–((%d%d%d%d?)%a?)");anchor_year=year..'–'..anchor_year;-- assemble anchor year from both yearsiftonumber(year)>=tonumber(year2)thenreturnfalse;end-- left to right, earlier to later, not the sameifnotis_valid_year(year2)thenreturnfalse;end-- no year farther in the future than next yearelseifdate_string:match("^[1-9]%d%d%d–%d%d%a?$")then-- Year range: YYYY–YY; separated by unspaced endashlocalcentury;year,century,anchor_year,year2=date_string:match("((%d%d)%d%d)–((%d%d)%a?)");anchor_year=year..'–'..anchor_year;-- assemble anchor year from both yearsif13>tonumber(year2)thenreturnfalse;end-- don't allow 2003-05 which might be May 2003year2=century..year2;-- add the century to year2 for comparisonsiftonumber(year)>=tonumber(year2)thenreturnfalse;end-- left to right, earlier to later, not the sameifnotis_valid_year(year2)thenreturnfalse;end-- no year farther in the future than next yearelseifdate_string:match("^[1-9]%d%d%d?%a?$")then-- year; here accept either YYY or YYYYanchor_year,year=date_string:match("((%d%d%d%d?)%a?)");iffalse==is_valid_year(year)thenreturnfalse;endelsereturnfalse;-- date format not one of the MOS:DATE approved formatsendlocalresult=true;-- check whole dates for validity; assume true because not all dates will go through this testif0~=yearand0~=monthand0~=dayand0==year2and0==month2and0==day2then-- YMD (simple whole date)result=is_valid_date(year,month,day);elseif0~=yearand0~=monthand0~=dayand0==year2and0==month2and0~=day2then-- YMD-d (day range)result=is_valid_date(year,month,day);result=resultandis_valid_date(year,month,day2);elseif0~=yearand0~=monthand0~=dayand0==year2and0~=month2and0~=day2then-- YMD-md (day month range)result=is_valid_date(year,month,day);result=resultandis_valid_date(year,month2,day2);elseif0~=yearand0~=monthand0~=dayand0~=year2and0~=month2and0~=day2then-- YMD-ymd (day month year range)result=is_valid_date(year,month,day);result=resultandis_valid_date(year2,month2,day2);endiffalse==resultthenreturnfalse;end-- if here, then date_string is valid; get coins_date from date_string (leave CITEREF disambiguator) ...coins_date=date_string:match("^(.+%d)%a?$");-- last character of valid disambiguatable date is always a digitcoins_date=mw.ustring.gsub(coins_date,"–","-");-- ... and replace any ndash with a hyphenreturntrue,anchor_year,coins_date;-- format is good and date string represents a real dateend--[[--------------------------< D A T E S >--------------------------------------------------------------------Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returnstrue. The |date= parameter test is unique, it is the only date holding parameter from which values for anchor_year (used in CITEREF identifiers) and COinS_date (used inthe COinS metadata) are derived. The |date= parameter is the only date-holding parameter that is allowed to contain the no-date keywords "n.d." or "nd" (without quotes).Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,a single error message is created as the dates are tested.]]--function p.dates(date_parameters_list)localfunctiondates(date_parameters_list)localanchor_year;-- will return as nil if the date being tested is not |date=localCOinS_date;-- will return as nil if the date being tested is not |date=localerror_message="";localmismatch=0;localgood_date=false;fork,vinpairs(date_parameters_list)do-- for each date-holding parameter in the listifis_set(v)then-- if the parameter has a valueifv:match("^c%. [1-9]%d%d%d?%a?$")then-- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=localyear=v:match("c%. ([1-9]%d%d%d?)%a?");-- get the year portion so it can be testedif'date'==kthenanchor_year,COinS_date=v:match("((c%. [1-9]%d%d%d?)%a?)");-- anchor year and COinS_date only from |date= parametergood_date=is_valid_year(year);elseif'year'==kthengood_date=is_valid_year(year);endelseif'date'==kthen-- if the parameter is |date=ifv:match("^n%.d%.%a?")then-- if |date=n.d. with or without a CITEREF disambiguatorgood_date,anchor_year,COinS_date=true,v:match("((n%.d%.)%a?)");--"n.d."; no error when date parameter is set to no dateelseifv:match("^nd%a?$")then-- if |date=nd with or without a CITEREF disambiguatorgood_date,anchor_year,COinS_date=true,v:match("((nd)%a?)");--"nd"; no error when date parameter is set to no dateelsegood_date,anchor_year,COinS_date=check_date(v);-- go test the dateendelseif'access-date'==kthen-- if the parameter is |date=good_date=check_date(v);-- go test the dateiftrue==good_datethen-- if the date is a valid dategood_date=is_valid_accessdate(v);-- is Wikipedia start date < accessdate < tomorrow's date?endelse-- any other date-holding parametergood_date=check_date(v);-- go test the dateendiffalse==good_datethen-- assemble one error message so we don't add the tracking category multiple timesifis_set(error_message)then-- once we've added the first portion of the error message ...error_message=error_message..", ";-- ... add a comma space separatorenderror_message=error_message.."|"..k.."=";-- add the failed parameterendendendreturnanchor_year,COinS_date,error_message,mismatch;-- and doneend--[[--------------------------< Y E A R _ D A T E _ C H E C K >------------------------------------------------Compare the value provided in |year= with the year value(s) provided in |date=. This function returns a numeric value: 0 - year value does not match the year value in date 1 - (default) year value matches the year value in date or one of the year values when date contains two years 2 - year value matches the year value in date when date is in the form YYYY-MM-DD and year is disambiguated (|year=YYYYx)]]localfunctionyear_date_check(year_string,date_string)localyear;localdate1;localdate2;localresult=1;-- result of the test; assume that the test passesyear=year_string:match('(%d%d%d%d?)');ifdate_string:match('%d%d%d%d%-%d%d%-%d%d')andyear_string:match('%d%d%d%d%a')then--special case where date and year required YYYY-MM-DD and YYYYxdate1=date_string:match('(%d%d%d%d)');year=year_string:match('(%d%d%d%d)');ifyear~=date1thenresult=0;-- years don't matchelseresult=2;-- years match; but because disambiguated, don't add to maint catendelseifdate_string:match("%d%d%d%d?.-%d%d%d%d?")then-- any of the standard formats of date with two three- or four-digit yearsdate1,date2=date_string:match("(%d%d%d%d?).-(%d%d%d%d?)");ifyear~=date1andyear~=date2thenresult=0;endelseifdate_string:match("%d%d%d%d[%s%-–]+%d%d")then-- YYYY-YY date rangeslocalcentury;date1,century,date2=date_string:match("((%d%d)%d%d)[%s%-–]+(%d%d)");date2=century..date2;-- convert YY to YYYYifyear~=date1andyear~=date2thenresult=0;endelseifdate_string:match("%d%d%d%d?")then-- any of the standard formats of date with one yeardate1=date_string:match("(%d%d%d%d?)");ifyear~=date1thenresult=0;endendreturnresult;endreturn{dates=dates,year_date_check=year_date_check}-- return exported functions