new-infofer-scraper/scraper/src/Utils/DateTimeSequencer.cs
Dan Cojocaru 7b13d09514
A whole C# rewrite
In one commit.
Yes, you're seeing it right.
Yes, I don't know what I was thinking.
2022-08-03 00:38:53 +03:00

25 lines
759 B
C#

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;
}
}
}
}