Reduce instantiation of CultureInfo
Some checks failed
Build .NET Project / build (push) Has been cancelled
Some checks failed
Build .NET Project / build (push) Has been cancelled
This commit is contained in:
@@ -11,6 +11,8 @@ namespace MarketData.Utils
|
||||
{
|
||||
public class FeedParser
|
||||
{
|
||||
private static readonly System.Globalization.CultureInfo cultureInfo = new System.Globalization.CultureInfo("en-US");
|
||||
|
||||
private FeedParser()
|
||||
{
|
||||
}
|
||||
@@ -58,6 +60,7 @@ namespace MarketData.Utils
|
||||
periodEnding = periodEnding.Replace("Period Ending", "");
|
||||
int length = periodEnding.Length;
|
||||
int index = 0;
|
||||
|
||||
while (index < length)
|
||||
{
|
||||
String strMonth = periodEnding.Substring(index, 3);
|
||||
@@ -69,7 +72,7 @@ namespace MarketData.Utils
|
||||
sb = new StringBuilder();
|
||||
for (int yIndex = 0; yIndex < 5; yIndex++) sb.Append(periodEnding[index++]);
|
||||
String strYear = sb.ToString().Trim();
|
||||
DateTime periodEndingDate = DateTime.ParseExact(strMonth + Utility.Pad(strDay, '0', 2) + strYear, "MMMddyyyy", new System.Globalization.CultureInfo("en-US"));
|
||||
DateTime periodEndingDate = DateTime.ParseExact(strMonth + Utility.Pad(strDay, '0', 2) + strYear, "MMMddyyyy", cultureInfo);
|
||||
periodEndingDates.Add(periodEndingDate);
|
||||
}
|
||||
return periodEndingDates;
|
||||
@@ -85,12 +88,12 @@ namespace MarketData.Utils
|
||||
strText = strText + " " + DateTime.Now.Year.ToString();
|
||||
string[] items = strText.Split(' ');
|
||||
strText = items[0] + "-" + Utility.Pad(items[1], '0', 2) + "-" + items[2];
|
||||
return DateTime.ParseExact(strText, "MMM-dd-yyyy", new System.Globalization.CultureInfo("en-US"));
|
||||
return DateTime.ParseExact(strText, "MMM-dd-yyyy", cultureInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
strText = strText.Replace(" ", "0");
|
||||
return DateTime.ParseExact(strText, "dd-MMM-yy", new System.Globalization.CultureInfo("en-US"));
|
||||
return DateTime.ParseExact(strText, "dd-MMM-yy", cultureInfo);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
|
||||
Reference in New Issue
Block a user