WikiCrawler/Tasks/Commons/TakenOnTemplate.cs
/// <summary>
/// Given existing date information, determines what should go in the date param of the infobox.
/// </summary>
Given existing date information, determines what should go in the date param of the infobox.
Given existing date information determines what should go in the date param of the infobox .
public static bool ReplaceDate(string date, string metadate, out string newcontent, out string yyyymmdd)
		{
			bool usingExif = false;
			yyyymmdd = "";
			if (string.IsNullOrEmpty(date))
			{
				if (string.IsNullOrEmpty(metadate))
				{
					newcontent = "{{other date|?}}";
					return true;
				}
				else
				{
					usingExif = true;
					date = metadate;
				}
			}
			bool hasDay;
			string isodate = DateToISO(date, out hasDay);
			if (string.IsNullOrEmpty(isodate))
			{
				if (!date.Equals("{{Taken on", StringComparison.InvariantCultureIgnoreCase)
					&& !date.Equals("{{Taken in", StringComparison.InvariantCultureIgnoreCase))
					LogError("'" + date + "' couldn't be parsed");
				newcontent = null;
				return false;
			}
			else if (hasDay)
			{
				yyyymmdd = isodate.Split(' ')[0];
				newcontent = "{{Taken on|" + isodate + "}}";
				if (usingExif) newcontent += " {{According to EXIF data}}";
				return true;
			}
			else
			{
				newcontent = "{{Taken in|" + isodate + "}}";
				if (usingExif) newcontent += " {{According to EXIF data}}";
				return true;
			}
		}
public static bool ReplaceDate ( string date , string metadate , out string newcontent , out string yyyymmdd ) { bool usingExif = false ; yyyymmdd = " " ; if ( string . IsNullOrEmpty ( date ) ) { if ( string . IsNullOrEmpty ( metadate ) ) { newcontent = " " ; return true ; } else { usingExif = true ; date = metadate ; } } bool hasDay ; string isodate = DateToISO ( date , out hasDay ) ; if ( string . IsNullOrEmpty ( isodate ) ) { if ( ! date . Equals ( " " , StringComparison . InvariantCultureIgnoreCase ) && ! date . Equals ( " " , StringComparison . InvariantCultureIgnoreCase ) ) LogError ( " " + date + " " ) ; newcontent = null ; return false ; } else if ( hasDay ) { yyyymmdd = isodate . Split ( ' ' ) [ 0 ] ; newcontent = " " + isodate + " " ; if ( usingExif ) newcontent += " " ; return true ; } else { newcontent = " " + isodate + " " ; if ( usingExif ) newcontent += " " ; return true ; } }
Given existing date information, determines what should go in the date param of the infobox.
Given existing date information determines what should go in the date param of the infobox .
//nothing to go on //try metadate //attempt to convert date to YYYY-MM-DD, YYYY-MM, or YYYY, with optional time //get rid of any time data for yyyymmdd //TODO: keep it afterward? /*if (!string.IsNullOrEmpty(metadate) && metadate != date)
            {
				LogError("EXIF date doesn't match stated date. Using stated.");
            }*/
date
string
metadate
string
string
out