microsoft / microsoft/AdaptiveCards

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

Open
#6,318 5 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area-Inconsistency Area-Renderers
Dominant language
C#
Stars
2k
Forks
595
Avg merge
1d 19h
Merged PRs (30d)
1

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue in the NodeJS target using the provided Card JSON and sample data, comparing DATE() and TIME() with and without fractional seconds. Done means millisecond-bearing date strings such as 2021-09-07T19:28:09.7315703+00:00 render correctly instead of leaving the expression unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, node.js
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.