I have made a file and add it on 08 Jul 2019 14:00:00 +0000
but I wanted to show in Bitbucket repository this timestamp: Mon, 08 Jul 2019 11:42:00 +0000.
so I did:
$ git commit -m"try444" --date="Mon, 08 Jul 2019 11:42:00 +0000"
then after the push the Bitbucket still show:08 Jul 2019 14:00:00 +0000
How to change the hour in Bitbucket server??
I have made a file and add it on 08 Jul 2019 14:00:00 +0000
but I wanted to show in Bitbucket repository this timestamp: Mon, 08 Jul 2019 11:42:00 +0000.
so I did:
$ git commit -m"try444" --date="Mon, 08 Jul 2019 11:42:00 +0000"
$ git commit -m"try444" --date="Mon, 08 Jul 2019 11:42:00 +0000"
Bitbucket still show:08 Jul 2019 14:00:00 +0000
Related
I have two timeranges
Fri, 02 Aug 2019 10:09:58 UTC +00:00..Fri, 02 Aug 2019 23:59:59 UTC +00:00
Fri, 02 Aug 2019 11:09:58 UTC +00:00..Fri, 02 Aug 2019 12:09:58 UTC +00:00
What's the simplest way to subtract the second from the first so I get
[
Fri, 02 Aug 2019 10:09:58 UTC +00:00..Fri, 02 Aug 2019 11:09:58 UTC +00:00,
Fri, 02 Aug 2019 12:09:58 UTC +00:00..Fri, 02 Aug 2019 23:59:59 UTC +00:00
]
I would do something like this:
range_1 = (Time.parse('2019-08-02 10:09:58 UTC') .. Time.parse('2019-08-02 23:59:59 UTC'))
range_2 = (Time.parse('2019-08-02 11:09:58 UTC') .. Time.parse('2019-08-02 12:09:58 UTC'))
[(range_1.begin..range_2.begin), (range_2.end..range_1.end)]
#=> [2019-08-02 10:09:58 UTC..2019-08-02 11:09:58 UTC, 2019-08-02 12:09:58 UTC..2019-08-02 23:59:59 UTC]
Could you please help me,
When i run rspec, i got this response.body
"{:id=>1, :email=>\"email1#example.com\", :live=>true, :is_confirmed=>false, :is_pro=>false, :user_profile=>nil, :user_settings=>nil, :subscription_end_at=>nil, :is_trialing=>nil, :created_at=>Mon, 19 Mar 2018 16:45:25 UTC +00:00, :updated_at=>Mon, 19 Mar 2018 16:45:25 UTC +00:00}"
But I want this
"{:id=>1, :email=>\"email1#example.com\", :live=>true, :is_confirmed=>false, :is_pro=>false, :user_profile=>nil, :user_settings=>nil, :subscription_end_at=>nil, :is_trialing=>nil, :created_at=>"Mon, 19 Mar 2018 16:45:25 UTC +00:00", :updated_at=>"Mon, 19 Mar 2018 16:45:25 UTC +00:00"}"
I just want to removed created_at and updated_at attribute from the response because it's give the datetime object instead of string
Event model which has start and end datetime attributes in the database. I want to seed some random events but the event time should be proper.
For example:
6.times { date_range << DateTime.now + (rand * 21) }
generates
[Thu, 03 Aug 2017 21:22:48 +0530,
Tue, 08 Aug 2017 17:36:29 +0530,
Sat, 29 Jul 2017 06:19:51 +0530,
Sat, 29 Jul 2017 13:36:21 +0530,
Thu, 27 Jul 2017 15:08:55 +0530,
Fri, 04 Aug 2017 13:53:03 +0530]
which is the correct behaviour.
But how to generate random datetime like this:
[Thu, 03 Aug 2017 21:00:00 +0530,
Tue, 08 Aug 2017 17:30:00 +0530,
Sat, 29 Jul 2017 06:00:00 +0530,
Sat, 29 Jul 2017 13:00:00 +0530,
Thu, 27 Jul 2017 15:30:00 +0530,
Fri, 04 Aug 2017 13:00:00 +0530]
So in order to display these events properly on a calendar.
Could try separating out each segment and adding them onto the date individually
date_range = 6.times.collect do
DateTime.now.beginning_of_day + # starting from today
rand(21).days + # pick a random day, no further than 3 weeks out
rand(24).hours + # move forward to a random hour on that day
(rand(2) * 30).minutes # and then decide whether to add 30 minutes
end
or, could combine the hours + minutes
date_range = 6.times.collect do
DateTime.now.beginning_of_day + # starting from today
rand(21).days + # pick a random day, no further than 3 weeks out
(rand(48) * 30).minutes # pick a random interval of 30 minutes to add in
end
Found the working solution but not complete:
6.times { date_range << DateTime.parse((DateTime.now + (rand * 21)).beginning_of_hour.to_s) }
[Mon, 31 Jul 2017 06:00:00 +0530,
Thu, 03 Aug 2017 15:00:00 +0530,
Fri, 11 Aug 2017 14:00:00 +0530,
Mon, 31 Jul 2017 09:00:00 +0530,
Wed, 09 Aug 2017 16:00:00 +0530,
Sat, 12 Aug 2017 13:00:00 +0530]
This can work for now but need some datetime with 30 minutes as well.
My db is by default storing times as such:
Object.last.created_at
# => Fri, 03 Jul 2015 23:27:50 UTC +00:00
I looked at the strftime docs and I can build that myself, but it seems there must be an easy way to get a regular Date object to that format? Just wondering if there is...
to_datetime gets really close, but not exactly all the way there.
Date.today.to_datetime
# => Sat, 04 Jul 2015 00:00:00 +0000
Any other ideas?
Try this
Time.zone.now
#=> Sat, 04 Jul 2015 20:32:44 UTC +00:00
UPDATE
DateTime.now.in_time_zone
#=> Sat, 04 Jul 2015 20:43:57 UTC +00:00
Oh silly me... it's just
Date.today.in_time_zone
# => Mon, 06 Jul 2015 00:00:00 UTC +00:00
We're in the timezone Bern, which is +0100. But since we're now in summertime (we have daylight saving time), the current offset is +0200. In my rails app, I set the timezone using a wrapper in the application controller since I need to have user-based timezones:
around_filter :user_timezone
def user_timezone(&block)
Time.use_zone(current_timezone, &block)
end
Now the strange part:
Time.zone.now # 2013-04-10 10:32:56 +0200
# (correct offset)
SomeArModel.first.created_at # 2013-03-28 17:49:59 +0100
# (incorrect offset, no DST)
Is there any explanation for this?
Thats normal behavior, the DST change happened on Sun Mar 31 01:00:00 UTC 2013.
t = Time.mktime(2013, 03, 31, 1, 15, 0)
6.times do
t += 900
u = Time.at(t.to_i).utc
puts t.to_s + " " + u.to_s
end
output:
Sun Mar 31 01:30:00 +0100 2013 Sun Mar 31 00:30:00 UTC 2013
Sun Mar 31 01:45:00 +0100 2013 Sun Mar 31 00:45:00 UTC 2013
Sun Mar 31 03:00:00 +0200 2013 Sun Mar 31 01:00:00 UTC 2013
Sun Mar 31 03:15:00 +0200 2013 Sun Mar 31 01:15:00 UTC 2013
Sun Mar 31 03:30:00 +0200 2013 Sun Mar 31 01:30:00 UTC 2013
Sun Mar 31 03:45:00 +0200 2013 Sun Mar 31 01:45:00 UTC 2013