From 5ef7505a94c59fcd6e97a5f314f463bc2fd2bf8f Mon Sep 17 00:00:00 2001 From: Noi Date: Wed, 23 Mar 2022 11:55:14 -0700 Subject: [PATCH] Add time zone to export, implements #4 --- ApplicationCommands/BirthdayModule.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/ApplicationCommands/BirthdayModule.cs b/ApplicationCommands/BirthdayModule.cs index c31f839..2a7fa34 100644 --- a/ApplicationCommands/BirthdayModule.cs +++ b/ApplicationCommands/BirthdayModule.cs @@ -221,7 +221,8 @@ public class BirthdayModule : BotModuleBase { select new { UserId = (ulong)row.UserId, Month = row.BirthMonth, - Day = row.BirthDay + Day = row.BirthDay, + Zone = row.TimeZone }; var result = new List(); @@ -234,7 +235,8 @@ public class BirthdayModule : BotModuleBase { BirthDay = row.Day, DateIndex = DateIndex(row.Month, row.Day), UserId = guildUser.Id, - DisplayName = Common.FormatName(guildUser, false) + DisplayName = Common.FormatName(guildUser, false), + TimeZone = row.Zone }); } return result; @@ -254,6 +256,7 @@ public class BirthdayModule : BotModuleBase { writer.Write(item.UserId); writer.Write(" " + user.Username + "#" + user.Discriminator); if (user.Nickname != null) writer.Write(" - Nickname: " + user.Nickname); + if (item.TimeZone != null) writer.Write(" | Time zone: " + item.TimeZone); writer.WriteLine(); } writer.Flush(); @@ -267,7 +270,7 @@ public class BirthdayModule : BotModuleBase { var writer = new StreamWriter(result, Encoding.UTF8); // Conforming to RFC 4180; with header - writer.Write("UserId,Username,Nickname,MonthDayDisp,Month,Day"); + writer.Write("UserId,Username,Nickname,MonthDayDisp,Month,Day,TimeZone"); writer.Write("\r\n"); // crlf line break is specified by the standard foreach (var item in list) { var user = guild.GetUser(item.UserId); @@ -283,6 +286,8 @@ public class BirthdayModule : BotModuleBase { writer.Write(item.BirthMonth); writer.Write(','); writer.Write(item.BirthDay); + writer.Write(','); + writer.Write(item.TimeZone); writer.Write("\r\n"); } writer.Flush(); @@ -325,6 +330,7 @@ public class BirthdayModule : BotModuleBase { public int BirthDay; public ulong UserId; public string DisplayName; + public string? TimeZone; } #endregion } \ No newline at end of file