Better fix for timezone offset, should add a pass in to the dashboard for timezone offset calculated in client

This commit is contained in:
Nathan Anderson 2023-08-02 11:40:41 -06:00
parent ef9a7d06e4
commit 6bba159e64
2 changed files with 8 additions and 5 deletions

View File

@ -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}"

View File

@ -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};