How to enter a YYYYMM date in Jekyll? - date

How should dates be entered in Jekyll?
I would like to enter the date "August 2018" in a YAML file to be used in Jekyll. I find lots of information on how to format already-existing dates, but pretty much nothing on how to enter them.
The best I have managed to find is Date formatting, which implies that dates entered in ISO 8601 format should be valid. If I run with this, then Wikipedia explicitly states
"2004-05" is a valid ISO 8601 date, which indicates May (the fifth
month) 2004.
This implies that "August 2018" could be entered as 2018-08.
However, when I use my YAML file my_data.yml in my _data folder
date: 2018-08
then Jekyll doesn't recognize it as a date as
{{ site.data.my_data.date | time: '%B %Y' }}
outputs "2018-08" and not "August 2018".

TL;DR: Enter YYYYMM dates such as "August 2018" as Aug 2018.
Searching through the Jekyll repo, I found the date filters. The Ruby on Rails method .to_formatted_s (source) seem to be key to most of them. In the source to that method dates are written as Tue, 04 Dec 2007 00:00:00 +0000 from which I guessed that I should write Aug 2018. Doing so in my_data.yml, the code outputs the expected “August 2018”.

Related

Convert a dates from Tweet hydrator to standard date format in Google Sheets mm/dd/yyyy

I have a large dataset (close to 80,000) of tweets dated like this:
Wed Oct 05 01:20:53 +0000 2016
What script can I run to convert the dates in Google Sheets to the simple mm/dd/yyyy form?
In this case, it should be: 10/05/2016
Thanks!
If the format of the date is you mentioned is consistent, you can use the below formula (assuming the date is in cell A1)
=DATEVALUE(RIGHT(A1,4) & MID(A1,5,3) & MID(A1,9,2))
This will extract the Datevalue from the string and then you can format it to look in the mm/dd/yyyy format
Try
=arrayformula(if(A1:A="",,1*(regexextract(A1,"\d{2}")&"/"&regexextract(A1,"\D+ (\D+) ")&"/"&regexextract(A1,".* (\d+)"))))
or (with hours/minutes/seconds)
=arrayformula(if(A1:A="",,1*(regexextract(A1,"\d{2}")&"/"&regexextract(A1,"\D+ (\D+) ")&"/"&regexextract(A1,".* (\d+)"))+regexextract(A1,"\d{2}:\d{2}:\d{2}")))
and define the appropriate format
Another solution
=index(ifna(Text(1&RegexExtract(A:A,".*?\s(.*?)\s"),"MM")&"/"&RegexExtract(A:A,"\d{2}")&"/"&RegexExtract(A:A,".*\s(.*)")))
Or
=index(text(regexreplace(regexreplace(A:A,"\+0000\s",),"(.*)(\d+:\d+:\d+)\s(.*)","$1$3 $2"),"mm/dd/yyyy"))
Or
=index(text(regexreplace(A:A,"(.*\s)(\d+:.*)\+.*\s(.*)","$1$3 $2"),"mm/dd/yyyy"))

How to convert a string date format `October 18th 2019` into a valid date `2019-10-17T23:00:00.000Z`

I need to convert a string date format like this October 18th 2019 ('MMMM Do YYYY') into a valid date 2019-10-17T23:00:00.000Z or similar 17/10/2019
i have tried using parsing the string into moment but i keep getting errors
update: I used moment('October 18th 2019').format(). received invalid date as the error, sorry I should clarify i'm trying to convert the string October 18th 2019 into a valid date format,
You simply need to supply the format string for the input (MMMM Do YYYY) when constructing the Moment object, with one of the following approaches:
// this way interprets the input at the start of the day in the local time zone
moment('October 18th 2019', 'MMMM Do YYYY')
// this way interprets the input at the start of the day in UTC
moment.utc('October 18th 2019', 'MMMM Do YYYY')
// this way interprets the input at the start of the day in a specific named time zone
// (requires the moment-timezone add-on)
moment.tz('October 18th 2019', 'MMMM Do YYYY', 'Europe/London')
Then you can format and/or convert it however desired. For example:
// this way keeps the local time, includes the local time offset when formatting
moment('October 18th 2019', 'MMMM Do YYYY').format()
// this way converts from local to utc before formatting
moment('October 18th 2019', 'MMMM Do YYYY').utc().format()
// this way converts from local to utc before formatting and includes milliseconds
moment('October 18th 2019', 'MMMM Do YYYY').toISOString()

Get week number according to your locale in Zend_Date

I am trying to get the current week number with Zend Framework.
In France, weeks are defined like this :
A week begins on Monday (whereas weeks begin on Sunday in the US).
The first week of the year is the week which contains the 4th of January.
In 2014, the first week begins January 1st. But if I use in Zend Framework 1.12 for this date like $zend_date->get(Zend_Date::WEEK) it returns 53 (and not 1). and for January 12th, it returns 1 (and not 2)
How can I correct that ? I already tried to change the locale to fr-fr but it didn't work.
Regards
Tried to replicate your problem doing
$date1 = new Zend_Date('2014-01-01');
$date2 = new Zend_Date('2014-01-12');
$date1->get(Zend_Date::WEEK) // gives 01
$date2->get(Zend_Date::WEEK) // gives 02
Also tried passing 'fr' as locale. It gives the correct answer.
I am not sure if it's a Zend issue.
Try the PHP solution:
php > echo date('W',strtotime('2014-01-01'));
01
php > echo date('W',strtotime('2014-01-12'));
02

Date value as float - Apple's iWork Numbers 09 - internal XML

I am writing a script in PHP which will convert Numbers file into HTML table, but I can not figure out which format is used for date storage. The date cell tag looks like
<sf:d
sf:s="SFTCellStyle-128"
sf:w="84.074219"
sf:h="14"
sf:cell-date="371397519.99999952" />
so the date must be in sf:cell-date attribute, but I can not figure out how to convert it into human readable format. Any ideas? I have never seen date value as float number.
As written in a comment, it is the number of seconds since 01/01/2001 at 00:00:00. Equipped with that knowledge and because this goes hand in hand with the UNIX Epoch all you need to do is to define and use the offset. It should be compatible with nearly every of the existing PHP date functions and objects, for example with date:
define('CELL_DATE_EPOCH_OFFSET', 978307200);
$sf_cell_date = 371397519.99999952;
echo date('r', CELL_DATE_EPOCH_OFFSET + $sf_cell_date);
The output of this little script is (in my timezone):
Mon, 08 Oct 2012 15:58:39 +0200
I hope this is helpful. 978307200 is the unix timestamp for 01/01/2001 00:00:00 UTC, you can get with PHP for example with the following code-example:
$base = new DateTime('01/01/2001 00:00:00 UTC');
echo $base->getTimestamp(), "\n";
in case that was your problem.

Groovy date parse issue

date.parse() method of groovy detects date DD and year yyyy correctly but is unable to detect the month as mmm.. As in
println new Date().parse("DD-MMM-yyyy", '22-MAR-2011')
yields output as
Sat Jan 22 00:00:00 GMT+05:30 2011
Why is the month march as MAR picked up as Jan? What can I do to make it detect the month in mmm format?
The problem is actualy that you are using DD - that means day in year
Correct way:
println new Date().parse("dd-MMM-yyyy", '22-MAR-2011')
Quick tip when formatting dates try using the reverse and see what comes out:
println new Date().format("dd-MMM-yyyy")
Groovy uses SimpleDateFormat under the hood but that's not that important since most date libraries use the same format conventions.