Add (potentially useless) DTS change
This commit is contained in:
parent
e4e52e711d
commit
f5af673e56
1 changed files with 28 additions and 25 deletions
53
scraper/src/Utils/DateTimeSequencer.cs
Normal file → Executable file
53
scraper/src/Utils/DateTimeSequencer.cs
Normal file → Executable file
|
|
@ -1,25 +1,28 @@
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace InfoferScraper {
|
namespace InfoferScraper {
|
||||||
public static partial class Utils {
|
public static partial class Utils {
|
||||||
public class DateTimeSequencer {
|
public class DateTimeSequencer {
|
||||||
private DateTime _current;
|
private DateTime _current;
|
||||||
|
|
||||||
public DateTimeSequencer(int year, int month, int day) {
|
public DateTimeSequencer(int year, int month, int day) {
|
||||||
_current = new DateTime(year, month, day);
|
_current = new DateTime(year, month, day);
|
||||||
_current = _current.AddSeconds(-1);
|
_current = _current.AddSeconds(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DateTimeSequencer(DateTime startingDateTime) {
|
public DateTimeSequencer(DateTime startingDateTime) {
|
||||||
_current = startingDateTime.AddSeconds(-1);
|
_current = startingDateTime.AddSeconds(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DateTime Next(int hour, int minute = 0, int second = 0) {
|
public DateTime Next(int hour, int minute = 0, int second = 0) {
|
||||||
DateTime potentialNewDate = new(_current.Year, _current.Month, _current.Day, hour, minute, second);
|
DateTime potentialNewDate = new(_current.Year, _current.Month, _current.Day, hour, minute, second);
|
||||||
if (_current > potentialNewDate) potentialNewDate = potentialNewDate.AddDays(1);
|
if (_current >= potentialNewDate) {
|
||||||
_current = potentialNewDate;
|
_current = potentialNewDate.AddDays(1);
|
||||||
return _current;
|
potentialNewDate = new(_current.Year, _current.Month, _current.Day, hour, minute, second);
|
||||||
}
|
}
|
||||||
}
|
_current = potentialNewDate;
|
||||||
}
|
return _current;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue