Skip to content

Commit

Permalink
Prepare fixing .NET UTC parse error (Z is being ignored)
Browse files Browse the repository at this point in the history
  • Loading branch information
Apollo3zehn committed Mar 13, 2024
1 parent cfc5560 commit cfb0f6b
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/Nexus.Sources.StructuredFile/StructuredFileDataSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,16 @@ async Task IDataSource.ReadAsync(

// get all candidate folders
var candidateFolders = fileSource.PathSegments.Length >= 1
? GetCandidateFolders(rootPath, default, begin, end, fileSource, fileSource.PathSegments, cancellationToken)

? GetCandidateFolders(
rootPath,
default,
begin,
end,
fileSource,
fileSource.PathSegments,
cancellationToken)

: new List<(string, DateTime)>() { (rootPath, default) };

return candidateFolders.SelectMany(currentFolder =>
Expand All @@ -731,7 +740,11 @@ async Task IDataSource.ReadAsync(
var candidateFiles = filePaths
.Select(filePath =>
{
var success = TryGetFileBeginByPath(filePath, fileSource, out var fileBegin, folderBegin: currentFolder.DateTime);
var success = TryGetFileBeginByPath(
filePath,
fileSource,
out var fileBegin,
folderBegin: currentFolder.DateTime);

return (success, filePath, fileBegin);
})
Expand Down Expand Up @@ -952,7 +965,7 @@ private static DateTime GetFolderBegin_AnyKind(string filePath, FileSource fileS
var folderBegin = default(DateTime);

var pathSegments = filePath
.Split('/', '\\');
.Split('/', '\\');

pathSegments = pathSegments
.Skip(pathSegments.Length - fileSource.PathSegments.Length - 1)
Expand Down
Empty file.
14 changes: 14 additions & 0 deletions tests/Nexus.Sources.StructuredFile.Tests/DATABASES/K/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"/A/B/C": {
"default": [
{
"PathSegments": [
"'DATA'"
],
"FileTemplate": "yyyy-MM-ddTHH-mm-ssZ'.dat'",
"FilePeriod": "1.00:00:00",
"UtcOffset": "00:00:00"
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Nexus.Extensibility" Version="2.0.0-beta.15" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public async Task CanProvideFirstFile()
[InlineData("DATABASES/H", "2019-12-31T12-00-00Z", "2020-01-02T00-20-00Z")]
[InlineData("DATABASES/I", "2019-12-31T23-55-00Z", "2020-01-01T00-15-00Z")]
[InlineData("DATABASES/J", "2020-01-01T00-00-00Z", "2020-01-05T00-00-00Z")]
[InlineData("DATABASES/K", "2020-01-01T00-00-00Z", "2020-01-02T00-00-00Z")]
public async Task CanProvideTimeRange(string root, string expectedBeginString, string expectedEndString)
{
var expectedBegin = DateTime.ParseExact(expectedBeginString, "yyyy-MM-ddTHH-mm-ssZ", null, DateTimeStyles.AdjustToUniversal);
Expand Down

0 comments on commit cfb0f6b

Please sign in to comment.