-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding feed sync import/export and fixing datetime parsing bug
--HG-- branch : dev
- Loading branch information
Albert Hajdu
committed
Sep 22, 2016
1 parent
d60274a
commit b152b6c
Showing
7 changed files
with
63 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Web; | ||
|
||
namespace Lombiq.FeedAggregator.Helpers | ||
{ | ||
/// <summary> | ||
/// Helper for parsing dates. | ||
/// </summary> | ||
public class DateTimeHelper | ||
{ | ||
/// <summary> | ||
/// Parses the given string to date. This is neccessary because the simple tryparse can't parse the | ||
/// date strings which ends with "EDT". | ||
/// </summary> | ||
/// <param name="dateString">The date string.</param> | ||
/// <param name="date">The parsed date.</param> | ||
/// <returns>True if the parse was successful.</returns> | ||
public static bool TryGetDateTime(string dateString, out DateTime date) | ||
{ | ||
// Checking if the simple tryparse can parse the date. | ||
date = new DateTime(); | ||
if (DateTime.TryParse(dateString, out date)) | ||
{ | ||
return true; | ||
} | ||
|
||
// If the given string ends with "EDT", then parse it manually. | ||
if (dateString.Substring(dateString.Length - 3) == "EDT") | ||
{ | ||
if (DateTime.TryParse(dateString.Substring(0, dateString.Length - 3) + " -0400", out date)) | ||
{ | ||
return true; | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters