microsoft / AdaptiveCards

A new way for developers to exchange card content in a common and consistent way.
https://adaptivecards.io
MIT License
1.76k stars 552 forks source link

DATE() and TIME() doesn't accept milliseconds in the date string. #6318

Open sridharvenkat opened 3 years ago

sridharvenkat commented 3 years ago

Target Platforms

NodeJS

SDK Version

1.3

Application Name

Microsoft Search results - https://docs.microsoft.com/en-us/microsoftsearch/customize-results-layout

Problem Description

DATE() and TIME() doesn't accept milliseconds in the date string. Though millisec based date string is parsed perfectly in JS and in .NET

E.g Data - "departureTime": "2021-09-07T19:28:09.7315703+00:00", Format - "text": "{{TIME(${string(reservationFor.departureTime)})}}", Result - {{TIME(2021-09-07T19:28:09.7315703+00:00)}}

Without the milliseconds in the string it works correctly.

E.g. Data - "arrivalTime": "2021-09-07T19:28:09+00:00", Format - "text": "{{TIME(${string(reservationFor.arrivalTime)})}}", Result - 12:28 PM

E.g. Data - "createdUtc": "2021-07-28T09:17:57.234Z", Format - "text": "{{TIME(${string(reservationFor.arrivalTime)})}}", Result - {{TIME(2021-07-28T09:17:57.234Z)}}

Without the milliseconds in the string it works correctly.

E.g. Data - "createdUtc": "2021-07-28T09:17:57Z", Format - "text": "{{TIME(${string(reservationFor.arrivalTime)})}}", Result - 2:17 AM

Screenshots

image

Card JSON

{
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "type": "AdaptiveCard",
    "version": "1.3",
    "speak": "<s>Flight KL0605 to San Fransisco has been delayed.</s><s>It will not leave until 10:10 AM.</s>",
    "body": [
        {
            "type": "ColumnSet",
            "columns": [
                {
                    "type": "Column",
                    "width": "auto",
                    "items": [
                        {
                            "type": "Image",
                            "size": "Small",
                            "url": "https://adaptivecards.io/content/airplane.png"
                        }
                    ]
                },
                {
                    "type": "Column",
                    "width": "stretch",
                    "items": [
                        {
                            "type": "TextBlock",
                            "text": "Flight Status",
                            "horizontalAlignment": "Right",
                            "isSubtle": true,
                            "wrap": true
                        },
                        {
                            "type": "TextBlock",
                            "text": "DELAYED",
                            "horizontalAlignment": "Right",
                            "spacing": "None",
                            "size": "Large",
                            "color": "Attention",
                            "wrap": true
                        }
                    ]
                }
            ]
        },
        {
            "type": "ColumnSet",
            "separator": true,
            "spacing": "Medium",
            "columns": [
                {
                    "type": "Column",
                    "width": "stretch",
                    "items": [
                        {
                            "type": "TextBlock",
                            "text": "Passengers",
                            "isSubtle": true,
                            "weight": "Bolder",
                            "wrap": true
                        },
                        {
                            "type": "TextBlock",
                            "text": "${underName.name}",
                            "spacing": "Small",
                            "wrap": true
                        },
                        {
                            "type": "TextBlock",
                            "text": "Jeremy Goldberg",
                            "spacing": "Small",
                            "wrap": true
                        },
                        {
                            "type": "TextBlock",
                            "text": "Evan Litvak",
                            "spacing": "Small",
                            "wrap": true
                        }
                    ]
                },
                {
                    "type": "Column",
                    "width": "auto",
                    "items": [
                        {
                            "type": "TextBlock",
                            "text": "Seat",
                            "horizontalAlignment": "Right",
                            "isSubtle": true,
                            "weight": "Bolder",
                            "wrap": true
                        },
                        {
                            "type": "TextBlock",
                            "text": "14A",
                            "horizontalAlignment": "Right",
                            "spacing": "Small",
                            "wrap": true
                        },
                        {
                            "type": "TextBlock",
                            "text": "14B",
                            "horizontalAlignment": "Right",
                            "spacing": "Small",
                            "wrap": true
                        },
                        {
                            "type": "TextBlock",
                            "text": "14C",
                            "horizontalAlignment": "Right",
                            "spacing": "Small",
                            "wrap": true
                        }
                    ]
                }
            ]
        },
        {
            "type": "ColumnSet",
            "spacing": "Medium",
            "separator": true,
            "columns": [
                {
                    "type": "Column",
                    "width": 1,
                    "items": [
                        {
                            "type": "TextBlock",
                            "text": "Flight",
                            "isSubtle": true,
                            "weight": "Bolder",
                            "wrap": true
                        },
                        {
                            "type": "TextBlock",
                            "text": "${reservationFor.flightNumber}",
                            "spacing": "Small",
                            "wrap": true
                        }
                    ]
                },
                {
                    "type": "Column",
                    "width": 1,
                    "items": [
                        {
                            "type": "TextBlock",
                            "text": "Departs",
                            "isSubtle": true,
                            "horizontalAlignment": "Center",
                            "weight": "Bolder",
                            "wrap": true
                        },
                        {
                            "type": "TextBlock",
                            "text": "{{TIME(${string(reservationFor.departureTime)})}}",
                            "color": "Attention",
                            "weight": "Bolder",
                            "horizontalAlignment": "Center",
                            "spacing": "Small",
                            "wrap": true
                        }
                    ]
                },
                {
                    "type": "Column",
                    "width": 1,
                    "items": [
                        {
                            "type": "TextBlock",
                            "text": "Arrives",
                            "isSubtle": true,
                            "horizontalAlignment": "Right",
                            "weight": "Bolder",
                            "wrap": true
                        },
                        {
                            "type": "TextBlock",
                            "text": "{{TIME(${string(reservationFor.arrivalTime)})}}",
                            "color": "Attention",
                            "horizontalAlignment": "Right",
                            "weight": "Bolder",
                            "spacing": "Small",
                            "wrap": true
                        }
                    ]
                }
            ]
        },
        {
            "type": "ColumnSet",
            "spacing": "Medium",
            "separator": true,
            "columns": [
                {
                    "type": "Column",
                    "width": 1,
                    "items": [
                        {
                            "type": "TextBlock",
                            "text": "${reservationFor.departureAirport.name}",
                            "isSubtle": true,
                            "wrap": true
                        },
                        {
                            "type": "TextBlock",
                            "text": "${reservationFor.departureAirport.iataCode}",
                            "size": "ExtraLarge",
                            "color": "Accent",
                            "spacing": "None",
                            "wrap": true
                        }
                    ]
                },
                {
                    "type": "Column",
                    "width": "auto",
                    "items": [
                        {
                            "type": "TextBlock",
                            "text": " ",
                            "wrap": true
                        },
                        {
                            "type": "Image",
                            "url": "https://adaptivecards.io/content/airplane.png",
                            "size": "Small"
                        }
                    ]
                },
                {
                    "type": "Column",
                    "width": 1,
                    "items": [
                        {
                            "type": "TextBlock",
                            "text": "${reservationFor.arrivalAirport.name}",
                            "isSubtle": true,
                            "horizontalAlignment": "Right",
                            "wrap": true
                        },
                        {
                            "type": "TextBlock",
                            "text": "${reservationFor.arrivalAirport.iataCode}",
                            "horizontalAlignment": "Right",
                            "size": "ExtraLarge",
                            "color": "Accent",
                            "spacing": "None",
                            "wrap": true
                        }
                    ]
                }
            ]
        }
    ]
}

SAMPLE DATA JSON

{
    "@context": "http://schema.org",
    "@type": "FlightReservation",
    "reservationId": "RXJ34P",
    "reservationStatus": "http://schema.org/ReservationConfirmed",
    "passengerPriorityStatus": "Fast Track",
    "passengerSequenceNumber": "ABC123",
    "securityScreening": "TSA PreCheck",
    "underName": {
        "@type": "Person",
        "name": "Sarah Hum"
    },
    "reservationFor": {
        "@type": "Flight",
        "flightNumber": "KL605",
        "provider": {
            "@type": "Airline",
            "name": "KLM",
            "iataCode": "KL",
            "boardingPolicy": "http://schema.org/ZoneBoardingPolicy"
        },
        "seller": {
            "@type": "Airline",
            "name": "KLM",
            "iataCode": "KL"
        },
        "departureAirport": {
            "@type": "Airport",
            "name": "Amsterdam Airport",
            "iataCode": "AMS"
        },
        "departureTime": "2021-09-07T19:28:09.7315703+00:00",
        "arrivalAirport": {
            "@type": "Airport",
            "name": "San Francisco Airport",
            "iataCode": "SFO"
        },
        "arrivalTime": "2021-09-07T19:28:09+00:00"
    }
}

Sample Code Language

No response

Sample Code

Used adaptive card designer - https://adaptivecards.io/designer

RebeccaAnne commented 3 years ago

@rahulamlekar Can you confirm whether milliseconds is supported by the version of the RFC 3339 (which we are documented to support)?

Since there is inconsistent behavior we'll need to follow up and fix one or the other.

paulcam206 commented 3 years ago

looks like fractional seconds are part of RFC3339 (see time-fraction)

sridharvenkat commented 3 years ago

Thanks for investigating this, I couldn't find a workaround other than string manipulation (removing the fractional seconds). Any better suggestions?

IntranetFactory commented 2 years ago

Do you have any plans to fix that or at least provide a workaround?

IntranetFactory commented 2 years ago

I now use {{DATE(${formatDateTime(duedate,'yyyy-MM-ddTHH:mm:ssZ')})}} as a workaround to remove the milliseconds