Skip to content

Commit

Permalink
Pattern matching for code readability
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-jitbit committed Jun 13, 2024
1 parent eb94e76 commit 7ac6ff7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions CsvExport/CsvExport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,15 @@ public static string MakeValueCsvFriendly(object value, string columnSeparator =
if (value is INullable && ((INullable)value).IsNull) return "";

string output;
if (value is DateTime)
if (value is DateTime date)
{
if (((DateTime)value).TimeOfDay.TotalSeconds == 0)
if (date.TimeOfDay.TotalSeconds == 0)
{
output = ((DateTime)value).ToString("yyyy-MM-dd");
output = date.ToString("yyyy-MM-dd");
}
else
{
output = ((DateTime)value).ToString("yyyy-MM-dd HH:mm:ss");
output = date.ToString("yyyy-MM-dd HH:mm:ss");
}
}
else
Expand Down

0 comments on commit 7ac6ff7

Please sign in to comment.