Gerrit search changes via 'before' statement and got some issue - gerrit

My Gerrit version is 3.1.2 and my timezone is
I have a change that created at 2020-05-07 21:27 and merged at 2020-05-07 21:32. Then I try to search this change.
I search by condition before: 2020-05-07 23:59:00 and cannot find this change.
I search by condition before: 2020-05-08 00:01:00 and this change was found.
Is there any idea about this issue or anyway to report this issue to Gerrit?
Thanks

I found the problem and share it. According the Gerrit document page: https://gerrit-review.googlesource.com/Documentation/user-search.html
🔗 before:'TIME'/until:'TIME'
Changes modified before the given 'TIME', inclusive. Must be in the format 2006-01-02[ 15:04:05[.890][ -0700]]; omitting the time defaults to 00:00:00 and omitting the timezone defaults to UTC.
Since the gerrit use the timezone as UTC, I need to add the time as [ -0700]. For example, if my timezone if UTC +4 hour, I need to search as
before "2020-05-07 21:40:00 +0400" and this issue will be solved. Please note that the " is required.
Thanks

Related

Why does my TZ environment variable takes the wrong effect in puppeteer?

Through the env-object for the method launch, we can set a TZ environment variable to affect the timezone of the browser. This is confirmed by an issue, where one explicitly mentions that.
I'm taking a screenshot of this page which shows a Google calendar. Setting puppeteer's TZ to US/Eastern yields times two hours later. Setting TZ to Brazil/East yields the correct US/Eastern time.
What am I missing here?
The machine timezone is actually set to UTC:
$ date
Fri Nov 30 17:09:55 UTC 2018

Gerrit time search operators is not working when specify to second

If i'm using
/changes/?q=status:merged+after:2018-08-25
it can return the result,
however if using
/changes/?q=status:merged+after:2018-08-25 00:00:00
it returns []
According to document, it is able to search time like this.
[[after_since]]
after:'TIME'/since:'TIME'::
+
Changes modified after the given 'TIME', inclusive. Must be in the
format `2006-01-02[ 15:04:05[.890][ -0700]]`; omitting the time defaults
to 00:00:00 and omitting the timezone defaults to UTC.
How to query when specify time to second? Is my format of parameters wrong?
When using:
/changes/?q=status:merged+after:2018-08-25 00:00:00
only the 2018-08-25 part is being used as the after: value. The 00:00:00 part is being used as a free text query term.
The value of after: should be enclosed in quotes:
/changes/?q=status:merged+after:"2018-08-25 00:00:00"
I was getting 400 Bad Request errors when running:
/changes/?q=status:merged+after:2018-08-25 00:00:00
What solved it is to enclose the time in quotes, but I also needed to replace the space between the date and time with the plus sign. E.g.:
/changes/?q=status:merged+after:"2018-08-25+00:00:00"

Why are those two datetimes different?

Why isn't Time.current equal to its parsed equivalent?
current = Time.current
# Wed, 16 Sep 2015 17:10:56 CEST +02:00
parsed = Time.zone.parse('16 Sep 2015 17:10:56')
# Wed, 16 Sep 2015 17:10:56 CEST +02:00
current == parsed
# false <= What ?!
current.to_i == parsed.to_i
# true
Ticket.create(datetime: current)
# ...
Ticket.find_by_datetime(parsed)
# nil <= Why ?!
I'm actually having trouble with this in a Ruby on Rails application where I try to find a record based on a datetime attribute that has been parsed, like shown on the last lines.
I really don't get it. Time zones are the same, times are the same down to seconds. What's happening here?
Moreover, how should I proceed to find a record based on a parsed datetime?
They should not be the same:
current.to_f #=> 1442417032.6567826
parsed.to_f #=> 1442417032.0
When parsing, you miss milliseconds.
Thanks everyone for the help. I hope you don't mind but since pieces of the final answer are scattered across multiple answers I will answer my own question building on what you all said.
So as for why the dates are different, it's because of the milliseconds missing in the parsed datetime. As #dimakura mentioned.
current.to_f #=> 1442417032.6567826
parsed.to_f #=> 1442417032.0
Then the answer about how could we fetch the Ticket record based a the parsed datetime.
First it's important to know this will be relevant only for PostgreSQL (my case) or other databases that actually store milliseconds. Thanks to #sjagr for mentioning this.
So we have to query for a range from parsed to parsed + 1 second, like #Stefan explained:
Ticket.where(datetime: parsed...parsed+1).first
And if we have control on the Ticket creation, we could also remove the millisecond precision before saving the the database. Thanks to #sjagr for providing an easy way to do that.
current = Time.current
Ticket.create(datetime: current.change(usec: 0))
Thanks everyone !
It's because they are not equal, they differ by parts of the second. What you see in the console is the result of inspect method called on those dates, which by default, drop any sub-second parts.

octopress's date_format not working

I comment the original data_format in _config.yml and have set the date format to another one(I tried several date format):
date_format: "%F %a" #2012-01-01
#date_format: "ordinal"
I rake generate and rake preview/or rake deploy, I still saw the date format is showing like "OCT 18TH, 2014 7:37 PM" , why is that?
Thank you!
First solution:
As far as I found the date_format parameter from _config.yml file is obsolete (I reported it in https://github.com/imathis/octopress/issues/1697) because the previous Octopress date plugin was replaced with Jekyll Date Format. The parameter is no longer used.
To change date format on your blog you have to edit source/_includes/post/date.html file. You just need to replace two occurrences of
{{ page.date_time_html }}
with the
{{ post.date | date: "%F" }}
Of course you can change the %F as you want. More about Jekyll Date Format you can find at: http://alanwsmith.com/jekyll-liquid-date-formatting-examples
Second solution:
I have checked the issue once again and now it works as it should. You do not need replace {{ page.date_time_html }} any more. Just follow the configuration of the Octopress Date Format plugin: https://github.com/octopress/date-format#configuration.
You need to add second option - time_format - for time formatting and everything should works properly.
Example:
date_format: "%Y-%m-%d" # e.g. 2014-07-03
time_format: "%H:%M" # 24 hour time
Summary:
Octopress is constantly developed project and the date format issue will probably be different on different commits at GitHub.

What timestamp is this?

I'm working with a Dataset which gives me a Time Variable for Objects, just like the created_at. The value tho is :
1398037671
Is this a special kind of encoding Timestamps or am i missing something ?
I guess it is "seconds since the Epoch" timestamp
Time.at(1398037671)
2014-04-21 01:47:51 +0200
http://www.ruby-doc.org/core-2.1.1/Time.html#method-c-at
That's a Unix timestamp. That specific timestamp represents 04 / 20 / 14 # 11:47:51pm UTC
You can find out more about them here: http://www.unixtimestamp.com/index.php and at good old wikipedia here: http://en.wikipedia.org/wiki/Unix_time
In Ruby, you can generate a Unix timestamp with Time.now.to_i (or obviously any other time if you don't want the timestamp for now).

Resources