Inverse function to format-date - date

in xslt 2.0, the function format-date will convert a date to string in a desired format, e.g.
<xsl:value-of select = "format-date(xs:date('2000-01-01'), '[D01] [MN,*-3] [Y0001]', 'en', (), ())"/>
results in
01 JAN 2000.
My question is: which function takes 01 JAN 2000 as input and outputs 2000-01-01?

As noted above:
XPath 3.1 adds parse-ietf-date() which handles many of the date formats used in internet standards such as email (which are often very US-oriented). But there are too many varieties of date formats out there for a general solution to be viable.
It's much easier to define a syntax for converting one input format to a wide variety of output formats than to do the converse. A syntax that is sufficiently powerful to do the job properly would end up being very similar to doing it "by hand" using the replace() function and regular expressions.
It's quite easy to DIY.
References
XSLT Date Formatting
Parsing Date/Time Information from Google XML feed using XSL Stylesheet

Related

How do I build an an expression using ADF expression language to dynamically generate date in yyyymmdd format for a speciific time zone?

I want to do something relatively straightforward please help I'm stuck
Given today's date is 02 May, 2021 in my current timezone (Pacific Standard Time), build the string 20210502 (yyyymmdd format) dynamically.
What is the simplest way to do this in ADF? I tried following but returns error invalid expression:
#substring(formatString(getutcdate()),0,8)
I'm also not sure how to make it flexible so I can enter a different timezone if I want like Pacific Standard Time.
You can create a timezone variable and pass that value to convertFromUtc or convertTimeZone function. And you can choose format as you need. Here is the format specifiers list.
You can follow this:
expression:#replace(split(convertFromUtc(utcnow(),variables('timezone'),'u'),' ')[0],'-','')
Output:

Google text-to-speech (Wavenet) Is there a list of date formats for each supported language?

Wavenet correctly converts dates like 01/02/2019 into a spoken date. Different languages use different date formats and separators e.g. dd/mm/yyyy and mm/dd/yyyy. Is there a list of date formats and separators for each supported Wavenet language?
Does Wavenet follow the country standard formats given in https://en.wikipedia.org/wiki/Date_format_by_country?
The great thing about Google's text-to-speech (as well as others, like Amazon's Polly) service is, that besides plain text that you seem to be using, it accepts SSML which stands for Speech Synthesis Markup Language. This allows you to provide XML tags to indicate how to pronounce certain parts of speech. Among them, dates:
<speak>
<say-as interpret-as="date" format="yyyymmdd" detail="1">
1960-09-10
</say-as>
</speak>
(Example taken from https://cloud.google.com/text-to-speech/docs/ssml#sayas)
As you surely know you can test this out directly in the browser here: https://cloud.google.com/text-to-speech/.

Formatting a java.util.Date through xsl built-in funciotn "format-dateTime" displays language

I'm using an xslt transformation to format a Java object to pdf through Apache FOP libraries.
In particular I want to format a field of my object, a java.util.Date into DD/MM/YYYY format. To be able to format using built-in function "format-dateTime" I set xslt version to 2.0 and switched the transformation processor to saxon-8.7 because xalan did not support version 2.0, then I added in the xslt the date formatting instruction as follows:
Value date: <xsl:value-of select="format-dateTime(valueDate, '[D01]/[M01]/[Y0001]') " />
before starting the transformation, I printed the Date field to stdout to be sure it was valued correctly in the input object:
valueDate: Thu Jan 01 01:00:00 CET 1970
And that's what I expected.
But in the output text, after the xsl transformation, appears an undesired "language" information that precedes the (correctly formatted) date.
[Language: en]01/01/1970
Someone knows why?
Why did you choose Saxon 8.7? It's a very old release, it actually predates the XSLT 2.0 recommendation of January 2007. The current release is 9.5.
I think you will find this goes away if you use a more recent release. However, it could still happen if your Java configuration has a default Locale which is a language that Saxon does not support. (The message indicates that Saxon has chosen to output the date in English despite this not being the language you requested, which is implicitly your default language).
If moving to a more recent release fails to solve the problem, try setting the language argument of format-date to the string "en".

Struggling with dates formats, want YYYY-MM-DD

As an absolute beginner to SAS I quickly ran into problems with date formatting.
I have a dataset containing transaction with three types of dates: BUSDATE, SPOTDATE, MATURITY. Each transaction is represented on two lines, and I want BUSDATE and SPOTDATE from line 1 but MATURITY from line 2.
In the original set, the dates are in YYYY-MM-DD format.
DATA masterdata;
SET sourcedata(rename(BUSDATE=BUSDATE2 SPOTDATE=SPOTDATE2 MATURITY=MATURITY2));
BUSDATE=BUSDATE2;
SPOTDATE=SPOTDATE2;
IF TRANS_TYPE='Swap' THEN;
MATURITY=SPOTDATE;
RUN;
Problem is, this returns something like 17169 (which I guess is the number of days from a certain date).
How can I make it output in YYYY-MM-DD format - or is this approach wrong; should I first convert the date variables to some SAS date format?
if you have valid SAS dates, just add a FORMAT statement to your DATA STEP.
Format busdate spotdate maturity yymmdd10. ;
SAS dates are numeric variables. They represent the number of days since 1/1/1960. You use a FORMAT to display dates.
Adding to CarolinaJay's answer, you normally want to keep them as numeric format, since you can do math (like "# of days since date X") with them. However, if for some reason you need a character variable, you can do this:
date_As_char=put(datevar,YYMMDD10.);
Incidentally, YYMMDD10 will actually give you YYYY-MM-DD, as you asked for; if you want a different separator, see http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000589916.htm (YYMMDDxw. format) - if you put a letter after the last D, for certain letters, you get a different separator. Like, YYMMDDn10. gives you no separator, or YYMMDDs10. gives you slashes. YYMMDDd10. gives you dashes, just like omitting the letter would. This concept also applies to MMDDYY formats, and I think a few others.

Which Perl module can handle a variety of date formats containing unicode characters?

My requirement is parsing xml files which contains wide varieties of timestamps based on the locales at which they are written. They may contain Unicode characters in case of Chinese or Korean locales. I have to parse these timestamps and put then in a standard format something like 2009-11-26 12:40:54 to put them in a oracle database. Sometimes I may not even know the locale and yet I have to parse the timestamps.
I am looking for a module that automatically detects the timestamp format (including unicode characters for am and pm in their local language) and converts in to epoch time so that I can convert it back to what ever way I like to.
I have gone through similar questions in this forum. Few suggested DateFormat module, and Date::Parse module. The perl distribution I am using is 5.10 so Date::Manip doesn't come as a core module. As I am supposed to use just the basic core modules and few CPAN modules(on request I cannot ask for all),
I request you to kindly suggest me a good module that suffices all my requirements.
Thanks in advance
DateTime::Locale should do what you want.
You might have a look at Date::Manip. Don't know if it supports the languages you need but there is some UTF8 support in it. In any case once you get the dates extracted it has a UnixDate method to easily output in whatever format you want. Also resolves time zones.