Skip to content

Commit

Permalink
Use TZ timezone instead of whatever I did 😅 Ty Eris 😊
Browse files Browse the repository at this point in the history
  • Loading branch information
GianniKoch committed Apr 13, 2024
1 parent 9348980 commit 6b4bb32
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 29 deletions.
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ services:
- Discord:Prefix=$DiscordPrefix
- Discord:Token=$DiscordToken
- Paths:DataFolderPath=/var/lib/poi/data
- TZ=$TZ
postgres:
image: postgres:16-alpine
ports:
Expand Down
18 changes: 2 additions & 16 deletions source/POI.DiscordDotNet/Jobs/BirthdayGirlsJob.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Runtime.InteropServices;
using DSharpPlus.Entities;
using DSharpPlus.Entities;
using JetBrains.Annotations;
using Microsoft.Extensions.Logging;
using NodaTime;
Expand Down Expand Up @@ -35,20 +34,7 @@ public async Task Execute(IJobExecutionContext context)
return;
}

var timeZoneId = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "Romance Standard Time" : "Europe/Brussels";
TimeZoneInfo? belgiumTimeZone;
try
{
belgiumTimeZone = TimeZoneInfo.FindSystemTimeZoneById(timeZoneId);
}
catch (TimeZoneNotFoundException)
{
_logger.LogError("Timezone {TimeZoneId} not found on this system", timeZoneId);
throw;
}

var localDate = LocalDate.FromDateTime(TimeZoneInfo.ConvertTimeFromUtc(context.ScheduledFireTimeUtc?.LocalDateTime ?? DateTime.Today, belgiumTimeZone));
//var localDate = LocalDate.FromDateTime(context.ScheduledFireTimeUtc?.LocalDateTime ?? DateTime.Today);
var localDate = LocalDate.FromDateTime(context.ScheduledFireTimeUtc?.LocalDateTime ?? DateTime.Today);

_logger.LogInformation("Looking up birthday party people using date: {Date}", localDate.ToString());
var currentBirthdayPartyPeople = await _globalUserSettingsRepository.GetAllBirthdayGirls(localDate.Day, localDate.Month);
Expand Down
14 changes: 1 addition & 13 deletions source/POI.DiscordDotNet/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,24 +115,12 @@
tp.MaxConcurrency = 5;
});
var timeZoneId = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "Romance Standard Time" : "Europe/Brussels";
TimeZoneInfo? belgiumTimeZone;
try
{
belgiumTimeZone = TimeZoneInfo.FindSystemTimeZoneById(timeZoneId);
}
catch (TimeZoneNotFoundException)
{
Log.Error("Timezone {TimeZoneId} not found on this system", timeZoneId);
throw;
}
q.ScheduleJob<RankUpFeedJob>(trigger => trigger
.WithIdentity("RankUpFeed Trigger")
.WithSchedule(CronScheduleBuilder.CronSchedule("0 0/5 * * * ?")));
q.ScheduleJob<BirthdayGirlsJob>(trigger => trigger
.WithIdentity("Birthday Girl trigger")
.WithCronSchedule(CronScheduleBuilder.DailyAtHourAndMinute(0, 0).InTimeZone(belgiumTimeZone)));
.WithCronSchedule(CronScheduleBuilder.DailyAtHourAndMinute(0, 0)));
})
.AddQuartzHostedService(options =>
{
Expand Down

0 comments on commit 6b4bb32

Please sign in to comment.