Do not build headers from empty time stamps.

This commit is contained in:
Daniel Kraus 2015-08-09 21:21:56 +02:00
parent 51bfdc760e
commit 6c9f003134
1 changed files with 30 additions and 2 deletions

View File

@ -30,14 +30,36 @@ namespace zaaReloaded2.Formatter
{
#region Static methods
/// <summary>
/// Builds a header paragraph from a Date,
/// but only if the Date structure has a value.
/// </summary>
public static string DateHeader(DateTime date)
{
return FormatHeader(date.ToShortDateString());
if (date != _nullTimeStamp.Date)
{
return FormatHeader(date.ToShortDateString());
}
else
{
return String.Empty;
}
}
/// <summary>
/// Builds a header paragraph from a DateTime structure,
/// but only if the DateTime structure has a value.
/// </summary>
public static string DateAndTimeHeader(DateTime dateTime)
{
return FormatHeader(dateTime.ToString());
if (dateTime != _nullTimeStamp)
{
return FormatHeader(dateTime.ToString());
}
else
{
return String.Empty;
}
}
#endregion
@ -119,5 +141,11 @@ namespace zaaReloaded2.Formatter
}
#endregion
#region Fields
static readonly DateTime _nullTimeStamp = new DateTime();
#endregion
}
}