mirror of
https://github.com/tonytins/PublishTimes.git
synced 2025-03-14 20:01:20 +00:00
Compare commits
2 commits
8ec45ad07c
...
c8dd778784
Author | SHA1 | Date | |
---|---|---|---|
c8dd778784 | |||
2d7cf1f6ca |
4 changed files with 50 additions and 3 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -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
|
||||
|
|
44
Program.cs
44
Program.cs
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue