You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wasn't sure to post this issue or not because I have no clue what is happening and I don't have much data, or at least I think.
I noticed some day calculations were not working properly in our app so I began troubleshooting it.
This date is returned through an API call. So my app receives some params and returns data, which includes this date.
If I run the request through my production web server, my date is off. However, every 10-15 requests, it would return the correct date.
If I run the same code through production console it is okay.
days = 2
now = 'Wed, 17 Mar 2021 20:15:16 EDT -04:00'.to_time
date = days.business_days.after(now).to_date
And it's returning Monday 22 2021 instead of Friday 18 2021.
I decided to add some debugging in production and also trying to fetch the date in a different way:
days = 2
now = 'Wed, 17 Mar 2021 20:15:16 EDT -04:00'.to_time
date = days.business_days.after(now).to_date
date2 = days.business_days.after(now.to_date)
if warehouse.code == 'MA' && days == 2 && date != '19 March 2021'.to_date
message = {
time_now: Time.now,
time_zone_now: Time.zone.now,
warehouse_local: now,
date: date,
date2: date2
}
Rails.logger.info(message)
end
date
The results were the following:
2021-03-18T00:15:16.468557+00:00 app[web.1]: I, [2021-03-18T00:15:16.468381 #210] INFO -- : {:time_now=>2021-03-18 00:15:16.468218979 +0000, :time_zone_now=>Thu, 18 Mar 2021 00:15:16 UTC +00:00, :warehouse_local=>Wed, 17 Mar 2021 20:15:16 EDT -04:00, :date=>Mon, 22 Mar 2021, :date2=>Fri, 19 Mar 2021}
2021-03-18T00:15:57.273594+00:00 app[web.1]: I, [2021-03-18T00:15:57.273391 #100] INFO -- : {:time_now=>2021-03-18 00:15:57.273113129 +0000, :time_zone_now=>Thu, 18 Mar 2021 00:15:57 UTC +00:00, :warehouse_local=>Wed, 17 Mar 2021 20:15:57 EDT -04:00, :date=>Mon, 22 Mar 2021, :date2=>Fri, 19 Mar 2021}
As you can see, date2 was calculated correct. I am fixing my issue this way, but there's definitely something off as running the same thing in console, same environment returns the correct date too.
The text was updated successfully, but these errors were encountered:
I wasn't sure to post this issue or not because I have no clue what is happening and I don't have much data, or at least I think.
I noticed some day calculations were not working properly in our app so I began troubleshooting it.
This date is returned through an API call. So my app receives some params and returns data, which includes this date.
If I run the request through my production web server, my date is off. However, every 10-15 requests, it would return the correct date.
If I run the same code through production console it is okay.
my config:
This is basically what's running:
And it's returning
Monday 22 2021
instead ofFriday 18 2021
.I decided to add some debugging in production and also trying to fetch the date in a different way:
The results were the following:
As you can see,
date2
was calculated correct. I am fixing my issue this way, but there's definitely something off as running the same thing in console, same environment returns the correct date too.The text was updated successfully, but these errors were encountered: