Skip to content

Commit

Permalink
Fixed a local time zone bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Apollo3zehn committed Jul 21, 2023
1 parent 9ce5496 commit 68d60bb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## v2.0.0-beta.4 - 2023-07-21

- Fixed a local time zone bug.

## v2.0.0-beta.4 - 2023-07-21

- Fixed UTC offset issues with file names without time part.

## v2.0.0-beta.3 - 2023-07-12
Expand Down
14 changes: 7 additions & 7 deletions src/Nexus.Sources.StructuredFile/StructuredFileDataSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -540,25 +540,25 @@ protected virtual Task<string[]> FindFilePathsAsync(DateTime begin, FileSource f
// 2020-01-01T00-00-00Z_v2.dat (contains data from time t0 + x to next midnight)
// Where x is the time period the system was offline to apply the new version.

var roundedBegin = begin.RoundDown(fileSource.FilePeriod);

var localBegin = roundedBegin.Kind switch
var localBegin = begin.Kind switch
{
DateTimeKind.Local => roundedBegin,
DateTimeKind.Utc => DateTime.SpecifyKind(roundedBegin.Add(fileSource.UtcOffset), DateTimeKind.Local),
DateTimeKind.Local => begin,
DateTimeKind.Utc => DateTime.SpecifyKind(begin.Add(fileSource.UtcOffset), DateTimeKind.Local),
_ => throw new ArgumentException("The begin parameter must have its kind property specified.")
};

var roundedLocalBegin = begin.RoundDown(fileSource.FilePeriod);

var folderNames = fileSource
.PathSegments
.Select(segment => localBegin.ToString(segment));
.Select(roundedLocalBegin.ToString);

var folderNameArray = new List<string>() { Root }
.Concat(folderNames)
.ToArray();

var folderPath = Path.Combine(folderNameArray);
var fileName = localBegin.ToString(fileSource.FileTemplate);
var fileName = roundedLocalBegin.ToString(fileSource.FileTemplate);

string[] filePaths;

Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version": "2.0.0",
"suffix": "beta.4"
"suffix": "beta.5"
}

0 comments on commit 68d60bb

Please sign in to comment.