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;
|
||||
|
||||
namespace InfoferScraper {
|
||||
public static partial class Utils {
|
||||
public class DateTimeSequencer {
|
||||
private DateTime _current;
|
||||
|
||||
public DateTimeSequencer(int year, int month, int day) {
|
||||
_current = new DateTime(year, month, day);
|
||||
_current = _current.AddSeconds(-1);
|
||||
}
|
||||
|
||||
public DateTimeSequencer(DateTime startingDateTime) {
|
||||
_current = startingDateTime.AddSeconds(-1);
|
||||
}
|
||||
|
||||
public DateTime Next(int hour, int minute = 0, int second = 0) {
|
||||
DateTime potentialNewDate = new(_current.Year, _current.Month, _current.Day, hour, minute, second);
|
||||
if (_current > potentialNewDate) potentialNewDate = potentialNewDate.AddDays(1);
|
||||
_current = potentialNewDate;
|
||||
return _current;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
|
||||
namespace InfoferScraper {
|
||||
public static partial class Utils {
|
||||
public class DateTimeSequencer {
|
||||
private DateTime _current;
|
||||
|
||||
public DateTimeSequencer(int year, int month, int day) {
|
||||
_current = new DateTime(year, month, day);
|
||||
_current = _current.AddSeconds(-1);
|
||||
}
|
||||
|
||||
public DateTimeSequencer(DateTime startingDateTime) {
|
||||
_current = startingDateTime.AddSeconds(-1);
|
||||
}
|
||||
|
||||
public DateTime Next(int hour, int minute = 0, int second = 0) {
|
||||
DateTime potentialNewDate = new(_current.Year, _current.Month, _current.Day, hour, minute, second);
|
||||
if (_current >= potentialNewDate) {
|
||||
_current = potentialNewDate.AddDays(1);
|
||||
potentialNewDate = new(_current.Year, _current.Month, _current.Day, hour, minute, second);
|
||||
}
|
||||
_current = potentialNewDate;
|
||||
return _current;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue