public static string ToStringJa(int?year, int?month, int?day) { DateUnitType type = GetType(year, month, day); string result = ""; switch (type) { case DateUnitType.YearMonthDay: result = string.Format(Resources.YearMonthDay, ToYearString(year), ToMonthString(month), ToDayString(day)); break; case DateUnitType.YearMonth: result = string.Format(Resources.YearMonth, ToYearString(year), ToMonthString(month)); break; case DateUnitType.Year: result = ToYearString(year) + Resources.Year; break; } return(result); }
public static DateTime?CreateDateTime(int?year, int?month, int?day) { DateUnitType type = GetType(year, month, day); DateTime? dateTime = null; switch (type) { case DateUnitType.YearMonthDay: dateTime = new DateTime(year.Value, month.Value, day.Value); break; case DateUnitType.YearMonth: dateTime = new DateTime(year.Value, month.Value, 1); break; case DateUnitType.Year: dateTime = new DateTime(year.Value, 1, 1); break; } return(dateTime); }
public static string ToString(DateUnit dateUnit) { if (dateUnit == null) { return(""); } DateUnitType type = dateUnit.DateUnitType; if (type == DateUnitType.YearMonthDay) { return(dateUnit.ToYearMonthDayString()); } else if (type == DateUnitType.YearMonth) { return(dateUnit.ToYearMonthString()); } else if (type == DateUnitType.Year) { return(dateUnit.ToYearString()); } return(""); }