From 6c9f003134cb0117455e03bc897a341e9b029986 Mon Sep 17 00:00:00 2001 From: Daniel Kraus Date: Sun, 9 Aug 2015 21:21:56 +0200 Subject: [PATCH] Do not build headers from empty time stamps. --- zaaReloaded2/Formatter/TimePointFormatter.cs | 32 ++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/zaaReloaded2/Formatter/TimePointFormatter.cs b/zaaReloaded2/Formatter/TimePointFormatter.cs index ab5ba9b..da8b41e 100755 --- a/zaaReloaded2/Formatter/TimePointFormatter.cs +++ b/zaaReloaded2/Formatter/TimePointFormatter.cs @@ -30,14 +30,36 @@ namespace zaaReloaded2.Formatter { #region Static methods + /// + /// Builds a header paragraph from a Date, + /// but only if the Date structure has a value. + /// public static string DateHeader(DateTime date) { - return FormatHeader(date.ToShortDateString()); + if (date != _nullTimeStamp.Date) + { + return FormatHeader(date.ToShortDateString()); + } + else + { + return String.Empty; + } } + /// + /// Builds a header paragraph from a DateTime structure, + /// but only if the DateTime structure has a value. + /// 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 } } \ No newline at end of file