Date Querying in Mongoid - ruby-on-rails

This has been asked a lot, but I'm still facing some issues with it.
I have date I receive and was storing as Date. I need to query on Greater Than and Less than, so I changed it to Time, tried it again, but I'm getting weird results.
I'm doing this
Class.where(:event_date.gt => Time.parse(Date.today))
and I'm getting old records, 1940s, 1960s and others. I tried converting time by adding .utc at the end, comparing against Date.today only, but nothing sovled the problem so far. This is the selector being generated by Mongoid
selector: {:date_utc=>{"$gte"=>Sat Sep 10 21:00:00 UTC 2011}},
I receive the date in this format "2011-09-11" and store it in the Time field. Tried parsing that as Time utc as well, no luck.
Any idea? I'm using Mongoid 2.0.2. Later versions seem incompatible with other extensions I'm using.
[UPDATE]
So the problem is with the old dates before 1970 apparently. How do I deal with them is the question now.

This is a known bug in Mongo. See ISSUE 405
The reason is that Mongo uses an unsigned number to store dates, so anything before the epoch rolls over far into the future.
Affortunately this issue has been fixed for stable version 2.0 released today. Upgrading to this version should solve your problem.

Related

Timezone test cases in project with user zone

I have already many test cases in which we are using saved dates in UTC format. But now I have to change some reports in PDF and I did used following method
def display_user_zone_date
model.created_at.in_time_zone(Time.now.utc_offset)
end
It is working perfectly. But issue is my test case failing. as I have hard coded date comparing with model
expect(model.display_user_zon_date).to eq 'YYYY Thu, 5 May 2021 05:00'
but it should be
expect(model.display_user_zon_date).to eq 'YYYY Thu, 5 May 2021 01:00'
I can change on local and it will work but issue is I have to run test cases on Github so again it will be different as per that machine time zones. And Is Time.zone.now gets browser time or system time. I think it is system time so how can I get browser time.
Any idea how can I fix it.
Time.zone.now gets the system time.
I think the easiest would be to add the time zone selector via a dropdown (you could also get the browser time zone via JavaScript) see the answers here: https://stackoverflow.com/a/12326821/9595653 (beware, some of the suggested gems are outdated).
For your issue with the tests I can recommend https://github.com/travisjeffery/timecop which allows you to set a specific time for a test.
And lastly, this article has some nice overall explanations: https://thoughtbot.com/blog/its-about-time-zones

Parse just went AWOL

1) I woke up this morning and my currentUser().objectId was different from what it has been the past 3 months. Now all of my personal data is lost and my profile is empty. My objectId is the same as my old one on the Parse dashboard. For some reason it's different on my device, and I've tried logging out/in repeatedly.
2) None of my queries are returning any objects. I've been using many of the same queries for months, all have worked great, but now they're not returning anything.
Is this Parse's fault? I have until April 28th to migrate my data so I shouldn't be expecting these results. Why is it going crazy?

How to interpret JIRA cumulative Creative vs Resolved graph

Recently I started to notice that we somehow have resolved more tickets than we've created. Since it seems paradoxical I can only come to two conclusions:
There is a bug in JIRA.
I don't understand what it is actually graphing.
…or both, I suppose. Here is a screenshot of a graph from this morning:
(The filter that is being graphed is a custom filter. I don't know if that's relevant.)
Is there an explanation for this beyond just "lol JIRA"?
This chart shows that your project has
71 issues that are unresolved and have a creation date within the given time period
79 issues that are resolved and have a resolved date within the given time period
It tells you that your stock of unresolved Issues has decreased by 8 between 22 Mar and 1 Apr.
Non-cumulative would show you a non-zero value only for the days where at least one issue has been created (red) or resolved (green).
From my point-of-view nothing to worry about. Projects mostly start with more issues created than resolved and work themselves into a good balance. Having resolved more than being created just means you have fixed several open issues and either not found new errors while testing or have not tested at all.

Will my app be ok for the next 2 months with parse.com?

I'm building an iPhone application for my final year project in college. I have been using parse.com as the backend for my app but am now worried that with parse shutting down it will effect my app when I need to present it in 2 months time. I know parse says they aren't shutting down till January 28, 2017 but I'm fearful there might be a lot of down time, especially as it seems their pushing people to migrate by April 28, 2016. Can someone please give me some insight into this? Or if anyone has a way of contacting Parse so I can see if i'll be OK
As far as I know, you should be fine. I am also dealing with the same problem and I haven't seen anything that says that the Parse backend won't work. I believe that it is only in January that it will stop working. But that gives you plenty of time to migrate your Parse Backend or to try other options.
Yes you're right, Parse will stay up until 2017. I personally won't worry about it too much, but if you want, you can spawn your own parse server as a backup.
https://github.com/ParsePlatform

Updating TimeZone from an application on windows mobile 6.1

I am trying to update the TimeZone of the windows mobile device from my application using the
OPenNetCF.WindowsCE.SetTimeZoneInformation call. It always sets the timezone to the standard timezone(ignores the day light timezone) when there are timezones with the same offset. To be clear, say I am trying to set the TimeZone to GMT-5 Eastern (new-york zone, which observes day light) from GMT-7 Arizona (mountain standard) and for some reason, it always sets the new time zone to GMT-5 Indiana (which doesn't observe day light settings).
To confirm if I am setting it correctly, after setting the timeZone, I did a GetTimeZOneInformation to see if the timezone what I set earlier is matching and it does. So, I dont know how this setting is getting messed up internally.
I don't find any documentation about setting the Timezone or adjusting the Local Times/System times from an application on windows mobile 6.1
Will I have to muck around registry settings to get this working?
I would appreciate any help on this.
Thanks,
A
After doing lot of research on the internet, I found a blog which posted the similar issue.
And the issue seems to be in the OpenNetCF. When they are populating the TZData structure for each TimeZone, they ignored the StandardDate(when the daylight ended) and DayLightDate(when the daylight started). Since, these were missing in each TimeZoneInformation object, the standard timezones were getting defaulted to.
Here is the link that I found for this issue.
Thanks,
A

Resources