react-intl FormattedDate Shows Prior Date for YYYY-MM-DD value - react-intl

Please note I'm new to react-intl. I have the following date I want to display:
d1_date: "2012-03-26" //goal to display March 26, 2012
I use react-intl's
FormattedDate
to display the date:
<FormattedDate value={d1_date} year='numeric' month='long' day='2-digit' />
and I get the following result:
March 25, 2012
I know the d1_date doesn't have time information. Do I need to manipulate d1_date so that a bogus time appears allowing the true date to reflect "March 26, 2012"?

<FormattedDate value={new Date('2012-03-26')} year='numeric' month='long' day='2-digit' />
I think it requires Date instance.

Related

In Coldfusion a certain date June 01, 2008 is not getting casted/parsed to datetime object while using “CreateODBCDateTime” method

<cfoutput>
<cfset mydate = 'June 01, 2008'>
<cfset JobStartDate=CreateODBCDateTime(mydate)>
</cfoutput>
Error:
Date value passed to date function createDateTime is unspecified or invalid.
Specify a valid date in createDateTime function.
Even isdate(mydate) // isdate('June 01, 2008') throws the exception.
Even *DateDiff // DateDiff('m', 'June 01, 2008', 'October 14, 2010') also gives exception.
It works okay with other dates for example: 'August 01, 2008', 'May 14, 2012' etc
I am using ColdFusion 2021 Update 3. Any help would be highly appreciated?
Adding a few more details in response to the comments:
Under JVM details Java Default Locale is en_US. Also by running GetLocale() gives me English (US).
The issue does'nt reproduce on cftry or cffiddle. But it can be reproduced if you install Coldfusion via Commandbox and try running the code.
Just do a lsParseDateTime to fix this. You are declaring that as a string so CF wont consider that as a date
<cfset JobStartDate = CreateODBCDateTime(lsParseDateTime(mydate, "en_US"))>

How to reformat this datetime without regex in Google Sheets?

In Google Sheets i want to reformat this datetime Mon, 08 Mar 2021 10:57:15 GMT into this 08/03/2021.
Using RegEx i achieve the goal with
=to_date(datevalue(REGEXEXTRACT("Mon, 08 Mar 2021 10:57:15 GMT","\b[0-9]{2}\s\D{3}\s[0-9]{4}\b")))
But how can i do it without RegEx? This datetime format seems to be a classic one - can it really be, that no onboard formula can't do it? I rather think, i miss the right knowledge here...
Please try the following formula and format as date
=TRIM(LEFT(INDEX(SPLIT(K13,","),,2),12))*1
(do adjust according to your locale)
Another option is to use Custom Script.
Example:
Code:
function formatDate(date) {
return Utilities.formatDate(new Date(date), "GMT", "dd/MM/YYYY")
}
Formula in B1: =formatDate(A1)
Output:
Reference:
Custom Functions in Google Sheets

display regular date for FormattedRelative

I want to display friendly format date just like whatsapp and telegram do. For example, for today's date it shows "today" and yesterday date it shows "yesterday". But I don't want to show three days before as "3 days ago". It should be the regular date like this "Sun, 7 Jul 2019".
I don't have any custom to the current code because it still uses the example from the repo. But I tried to change the format but none of that works.
What does your code look like? You'd have to do some logic like
if (daysAgo > -2) {
return <FormattedRelativeTime numeric="auto" unit="day" value={daysAgo} />
}
return <FormattedDate weekday="short" day="numeric" month="short" year="numeric" value={ts} />

Extract Date and Time in ABAP via Regex

I wanted to separate the time and date from this string using REGEX because I feel like it is the only way I can separate it. But I am not really familiar on how to do it maybe someone can help me out here.
The original string: Your item was delivered in or at the mailbox at 3:34 pm on September 1, 2016 in TEXAS, MT 59102
The output i want to achieve/populate:
lv_time = 3:34 pm
lv_date = September 1, 2016
Here's the code I was trying to do but I am only able to cut it like this:
lv_status = Your item was delivered in or at the mailbox at
lv_time = 3
lv_date = :34 pm on September 1, 2016 in TEXAS, MT 59102.
Here's the code I have so far:
DATA: lv_status TYPE string,
lv_time TYPE string,
lv_date TYPE string,
lv_off TYPE i.
lv_status = 'Your item was delivered in or at the mailbox at 3:34 pm on September 1, 2016 in TEXAS, MT 59102.'.
FIND REGEX '(\d+)\s*(.*)' IN lv_status SUBMATCHES lv_time lv_date MATCH OFFSET lv_off.
lv_status = lv_status(lv_off).
You asked for it, here it comes:
\b((1[0-2]|0?[1-9]):([0-5][0-9]) ([AaPp][Mm])) on (January|February|March|April|May|June|July|August|September|October|November|December)\D?(\d{1,2}\D?)?\D?((?:19[7-9]\d|20\d{2})|\d{2})
This accepts time in HH:MM am/pm format, and dates in Jan-Dec, dd 1970-2999.
Each part is captured in its own group.
The demo shows a version that allows abbreviated month names:
Demo

Matching diverse dates in Openrefine

I am trying to use the value.match command in OpenRefine 2.6 for splitting the information presents in a column into (at least) 2 columns.
The data are, however, quite messed up.
I have sometimes full dates:
May 30, 1949
Sometimes full dates are combined with other dates and attributes:
May 30, 1949, published 1979
May 30, 1949 and 1951, published 1979
May 30, 1949, printed 1980
May 30, 1949, print executed 1988
May 30, 1949, prints executed 1988
published 1940
Sometimes you have timespan:
1905-05 OR 1905-1906
Sometimes only the year
1905
Sometimes year with attributes
August or September 1908
Doesn't seems to follow any specific schema or order.
I would like to extract (at least)ca start and end date year, in order to have two columns:
-----------------------
|start_date | end_date|
|1905 | 1906 |
-----------------------
without the rest of the attributes.
I can find the last date using
value.match(/.*(\d{4}).*?/)[0]
and the first one with
value.match(/.*^(\d{4}).*?/)[0]
but I got some trouble with the two formulas.
The latter cannot match anything in case of:
May 30, 1949 and 1951, published 1979
while in the case of:
Paris, winter 1911-12
The latter formula cannot match anything and the former formula match 1911
Anyone know how I can resolve the problem?
I would need a solution that take the first date as start_date and final date as end_date, or better (don't know if it is possible) earliest date as start_date and latest date as end_date.
Moreover, I would be glad to have some clue about how to extract other information, such as
if published or printed or executed is present in the text -> copy date to a new column name “execution”.
should be something like create a new column
if(value.match("string1|string2|string3" + (\d{4}), "perform the operation", do nothing)
value.match() is a very useful but sometimes tricky function. To extract a pattern from a text, I prefer to use Python/Jython's regular expressions :
import re
pattern = re.compile(r"\d{4}")
return pattern.findall(value)
From there, you can create a string with all the years concatenated:
return ",".join(pattern.findall(value))
Or select only the first:
return pattern.findall(value)[0]
Or the last:
return pattern.findall(value)[-1]
etc.
Same thing for your sub-question:
import re
pattern = re.compile(r"(published|printed|executed)\s+(\d+)")
return pattern.findall(value)[0][1]
Or :
import re
pattern = re.compile(r"(published|printed|executed)\s+(\d+)")
m = re.search(pattern, value)
return m.group(2)
Example:
Here is a regex which will extract start_date and end_date in named groups :
If there is only one date, then it consider it's the start_date :
((?<start_date>\d{4}).*?)?(?<end_date>\d{4}|(?<=-)\d{2})?$
Demo