Skip to content

XSLT extension methods format-date & format-time both output date & time when using the empty string (default) format #93189

Open
@Dave-Lowndes

Description

@Dave-Lowndes

Description

I'm porting a .NET FW application to .NET (6 and above).
The application performs an XML to HTML conversion using an XSLT transform via System.Xml.Xsl.XslCompiledTransform.

Under .NET FW, this XSL line:

<xsl:value-of select="ms:format-date('2001-02-03T01:02:03', '')"/>

Produces:

03/02/2001

UK date format since that's my locale.

However, under .NET 6 (I've also tried 8), it produces:

03/02/2001 01:02:03

Similarly, the format-time function also outputs both the date & time.

Reproduction Steps

It's easy to see there's a problem from the identified source code.

Expected behavior

The default (empty) format string should cause format-date() to output just the date, and correspondingly, format-time() to output just the time - as was the case under .NET FW and is how the functions are documented.

Actual behavior

Both functions output both the date and time.

Regression?

Yes, the functions works as documented for .NET FW.

Known Workarounds

Don't use the default (empty) format string - pass either "d" or "T" to the functions.

Configuration

.NET 6 and above (I've not tried anything < 6)

Other information

Looking at the .NET source code, the issue seems to be in the MSFormatDateTime function. Note that the function doesn't use the "isDate" parameter.

Compare that code with the .NET FW version which clearly uses the isDate parameter to do just the Date or Time appropriately.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-System.Xmlbuggood first issueIssue should be easy to implement, good for first-time contributorsin-prThere is an active PR which will close this issue when it is merged

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions