From 6bba159e64b7f0903a4d5282aa2c3617fe603a5e Mon Sep 17 00:00:00 2001 From: Nathan Anderson Date: Wed, 2 Aug 2023 11:40:41 -0600 Subject: [PATCH] Better fix for timezone offset, should add a pass in to the dashboard for timezone offset calculated in client --- data_backup.sh | 2 +- src/routes/transactions.zig | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/data_backup.sh b/data_backup.sh index f82a115..63ce48f 100755 --- a/data_backup.sh +++ b/data_backup.sh @@ -12,6 +12,6 @@ dst_file="data-${timestamp}.db" mkdir -p $dst_dir # Move and rename the file -mv "${src}" "${dst_dir}/${dst_file}" +cp "${src}" "${dst_dir}/${dst_file}" echo "File has been moved to ${dst_dir} and renamed to ${dst_file}" \ No newline at end of file diff --git a/src/routes/transactions.zig b/src/routes/transactions.zig index 1214a79..9f231e4 100644 --- a/src/routes/transactions.zig +++ b/src/routes/transactions.zig @@ -13,11 +13,14 @@ pub fn fetchTransFromDb(allocator: std.mem.Allocator, family_id: u32) !?[]models var db = handler.getDb(); const now = time.Datetime.now(); var beginning_of_month = try time.Datetime.fromDate(now.date.year, now.date.month, 1); - const timezone_begin = beginning_of_month.shiftTimezone(&tz.US.Mountain); - // std.log.info("Beginning: {} Shifted: {}", .{ beginning_of_month.date.toTimestamp(), timezone_begin.date.toTimestamp() }); - const begin_time = @bitCast(u64, timezone_begin.date.toTimestamp()); + // const timezone_begin = beginning_of_month.shiftTimezone(&tz.US.Mountain); - // std.log.info("Fetching transactions after beginning of month: unix {}", .{begin_time}); + const timezone_begin = beginning_of_month.shiftHours(6); + // std.log.info("Beginning: {} Shifted: {}", .{ beginning_of_month.date.toTimestamp(), timezone_begin.date.toTimestamp() }); + // const unix = @bitCast(u64, beginning_of_month.date.toTimestamp() + beginning_of_month.time.toTimestamp()); + const begin_time = @bitCast(u64, timezone_begin.date.toTimestamp() + timezone_begin.time.toTimestamp()); + + // std.log.info("Fetching transactions after beginning of month: unix {}, adjusted {}", .{ unix, begin_time }); comptime { if (!std.mem.eql(u8, @typeInfo(models.Transaction).Struct.fields[7].name, "date")) { return error{TransactionModelError};