Compare commits

...

2 commits

Author SHA1 Message Date
c8dd778784 Options to export schedule 2025-03-11 16:51:25 -04:00
2d7cf1f6ca Minor tweaks
- Renamed LICENSE to UNLICENSE
2025-03-11 16:09:39 -04:00
4 changed files with 50 additions and 3 deletions

3
.gitignore vendored
View file

@ -543,4 +543,5 @@ FodyWeavers.xsd
# Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option)
.idea/**
.idea/**
*.txt

View file

@ -1,9 +1,11 @@
// I hereby waive this project under the public domain - see UNLICENSE for details.
const string banner = "=== Publish Times ===";
var numberOfArticles = 5; // Define how many articles to schedule
var startTime = new TimeSpan(9, 0, 0); // Starting time at 9:00 AM
var random = new Random();
var scheduledTimes = new List<TimeSpan>();
var storeSchedule = new List<String>();
for (int i = 0; i < numberOfArticles; i++)
{
@ -39,6 +41,46 @@ string TimeSpanToAMPM(TimeSpan time)
Console.WriteLine(banner);
foreach (var time in scheduledTimes)
{
var articleTime = $"Article {scheduledTimes.IndexOf(time) + 1} Scheduled at: {TimeSpanToAMPM(time)}";
// Correct format string to display time in 12-hour format with AM/PM
Console.WriteLine($"Article {scheduledTimes.IndexOf(time) + 1} Scheduled at: {TimeSpanToAMPM(time)}");
Console.WriteLine(articleTime);
// Store the schedule to memory for option export
storeSchedule.Add(articleTime);
}
// Give the user an option to export the schedule
Console.WriteLine("Export? Y/N");
if (Console.ReadKey().Key == ConsoleKey.Y)
{
var appPath = Directory.GetCurrentDirectory();
var scheduleFile = "schedule.txt";
var filePath = Path.Combine(appPath, scheduleFile);
var appendSchedule = false;
// If the file already exists, assume the schedule was written
if (File.Exists(filePath))
{
Console.WriteLine($"{Environment.NewLine}Add another schedule? Y/N");
if (Console.ReadKey().Key == ConsoleKey.Y)
appendSchedule = true;
}
// Write to file.
using (var outputFile = new StreamWriter(Path.Combine(appPath, scheduleFile), appendSchedule))
{
// Add separator between times
if (appendSchedule)
outputFile.WriteLine(" ---");
foreach (var line in storeSchedule)
outputFile.WriteLine(line);
}
// Clear list and start over
storeSchedule.Clear();
}
else
{
Environment.Exit(Environment.ExitCode);
}

View file

@ -1,6 +1,10 @@
# Publish Times
This is a very simple console application that generates a list of times to schedule news with a 2-3 hour delay with a 30 minute time gap per-article.
This is a very simple console application that generates a list of times to schedule news with a 2-3 hour delay and a 30 minute time gap per-article.
## Background
A while back, I [found a tool](https://schedule.lemmings.world) to schedule articles on Lemmy. I've been posting within a few hour apart at random minutes and I wanted to something decide that for me. I had AI write the algorithm.
## License

View file