Skip to content

Commit

Permalink
enhance time parsing to support additional formats
Browse files Browse the repository at this point in the history
  • Loading branch information
hkutluay committed Dec 26, 2023
1 parent 0e05660 commit 67d51bf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 20 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"dotnet-test-explorer.testProjectPath": "UblTr.Tests/"
}
21 changes: 4 additions & 17 deletions Ubl-Tr/Common/UnqualifiedDataTypes/TimeType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,6 @@ namespace UblTr.Common
[System.Xml.Serialization.XmlTypeAttribute(Namespace = "urn:oasis:names:specification:ubl:schema:xsd:UnqualifiedDataTypes-2")]
public partial class TimeType
{

private List<string> applicableTimeFormats = new List<string> {
"HH:mm:ss",
"HH:mm",
"HH:mm:ss.fffff",
"HH:mm:ss.fffffff",
"HH:mm:ss.fffffffzzz",
"HH:mm:ss.fffzzz",
"HH:mm:ss.fffffffZ"
};

private System.DateTime valueField;

/// <remarks/>
Expand All @@ -77,13 +66,11 @@ public String TimeString
bool parsed = false;
DateTime parsedValue;

foreach (var format in applicableTimeFormats)

if(DateTime.TryParse(value,CultureInfo.InvariantCulture, DateTimeStyles.None, out parsedValue))
{
if(DateTime.TryParseExact(value, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out parsedValue))
{
this.valueField = parsedValue;
parsed = true;
}
this.valueField = parsedValue;
parsed = true;
}

if(!parsed)
Expand Down
6 changes: 3 additions & 3 deletions Ubl-Tr/UblTr.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
<RepositoryType>Github</RepositoryType>
<PackageTags>ubltr ubl-tr e-invoice ubl ubl-tr-1.2.1 e-fatura fatura efatura e-despatch eirsaliye irsaliye applicationresponse uygulamayaniti creditnote receiptadvice </PackageTags>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Version>1.3.0</Version>
<Version>1.3.1</Version>
<PackageIcon>icon.png</PackageIcon>
<AssemblyVersion>1.3.0.0</AssemblyVersion>
<FileVersion>1.3.0.0</FileVersion>
<AssemblyVersion>1.3.1.0</AssemblyVersion>
<FileVersion>1.3.1.0</FileVersion>
</PropertyGroup>
<ItemGroup>
<None Include="Images\icon.png">
Expand Down

0 comments on commit 67d51bf

Please sign in to comment.