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.
Related
I've got date as string '2020-02-10 8,00' which I want to convert into Monday, 10th of February. I'm aware of this old topic however I cannot find (or use) any related information.
All I have is just parsed string to date - Date.parse '2020-02-10 8,00'
You are halfway there! Date.parse '2020-02-10 8,00' produces a ruby Date object, as you have noted. You now have to apply strftime. However strftime doesn't have any ordinalization so that piece has to be done manually.
date = Date.parse('2020-02-10 8,00')
date.strftime("%A, #{date.day.ordinalize} of %B") #=> Monday, 10th of February
the ordinalize method is provided by ActiveSupport.
If this format will be used multiple times in your app, you may wish to add an app-wide format:
# in config/initializers/time_formats.rb
Date::DATE_FORMATS(:ordinalized_day) = lambda{|date| date.strftime("%A, #{date.day.ordinalize} of %B")}
# anywhere in the app
Date.today.to_formatted_s(:ordinalized_day)
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
We've have a curious (timezone?) problem around the testing of Date/Time in a Rails application.
The date being tested is created_at on a Rails object.
On the front end (.html.slim page with some AngularJS)
span.date
| {{ comment.createdAt }}
Renders:
2017-01-03T00:00:00.000Z
but...
span.date
| {{ comment.createdAt | moment: 'MMMM Do, YYYY' }}
Renders:
January 2nd, 2017
We are expecting January 3rd, 2017
I've tried moment.utc: 'MMMM Do, YYYY' but yields nothing.
Thoughts?
EDIT Background to how date is set on Comment object in spec.
A date object is created with Date.parse
Timecop freezes time
Comment object is created
Comment.created_at is rendered on a page but it is adjusted for the local time (this is expected behavior)
Perhaps with Timecop frozen there's a better way to set current_date so that when momentJS thaws it out it's in the same timezone that machine where tests are being run is?!?
let!(:current_date) { Date.parse('2017-01-03') }
...
background do
Timecop.freeze(current_date)
end
...
context 'for story' do
background do
open_story_comments_modal
within '.story-comments-container' do
add_comment 'First comment message'
end
end
...
and in a shared helper we have
def add_comment(text)
fill_in 'comment[body]', with: text
find('input[name="comment[body]"]').send_keys(:enter)
expect(page).to have_css '.comments .comment-body', text: text
end
2017-01-03T00:00:00.000Z is an ISO 8601 date string. The Z at the end indicates that it's in UTC timezone. Depending on locale timezone that date may be on January 3rd or January 2nd.
Storing a date with time and timezone is often a good idea but not in some edge cases. If you want to store a day, you shouldn't store a time and must not store a timezone. A date string without timezone is considered to be in locale time:
If the time zone offset is absent, the date-time is interpreted as a local time.
ECMAScript 2015 (6th edition): 20.3.1.16 Date Time String Format
Please note that this has changed since ECMAScript 2015 (6th edition). Until before it was specified as the opposite:
The value of an absent time zone offset is "Z".
ECMAScript 5.1 Edition / June 2011: 15.9.1.15 Date Time String Format
As far as I know all browser followed that change some time ago.
I want the date to be day, month, year. i.e. Jan 1, 2015. How can I change the format to this and what file should I put it in?
I want the date to show up in this format within index.html.erb and in the _form.html.erb.
I accidentally did a scaffold as datetime, but manually changed everything back to date, then ran rake db:reset. Now when I create something the date comes up as: 2014-12-31 00:00:00 UTC.
Thanks for any help you could give me!
Use strftime to format your dates into formatted strings.
DateTime.now.strftime("%d/%m/%y")
Edit
In a rails view
<%= DateTime.now.strftime("%d/%m/%y") %>
I have a birthday field in my database which has a date value as yyyy-mm-dd. I want to display it as being more human friendly. So 2011-11-15 should show up as Tuesday, November 15th, 2011.
The very strange thing is that when i do a #user.birthday in rails console, the value does show up in the format I want. But not on the web.
I am not sure what's going on.
The reason it does not show up in the right format is that Rails in the view does call a to_s if necessary.
You should the Internationalization and Localization of Rails to do that.
So in your example, I18n.l #user.birthday should do the trick. You should check what the default date format for your locale is, this is located at `config/locales/.yml. You may add your format by following the explanation in "How to store custom translations". So by adding
en:
date:
formats:
default: "%A, %B %d,%Y"
this format will be used where ever you call I18n.l on a date.
#user.birthday.strftime "%A, %B %d,%Y"
Try this <model>.created_at.to_date.to_s(:long)