question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
paulcam206commented, Sep 13, 2021

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

0reactions
IntranetFactorycommented, Apr 6, 2022

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - new Date(milliseconds) returns Invalid date
You're not using a number, you're using a string that looks like a number. According to MDN, when you pass a string into...
Read more >
Date and time
Returns the timestamp for the date – a number of milliseconds passed from the January 1st of 1970 UTC+0. getTimezoneOffset(). Returns the ...
Read more >
The Definitive Guide to DateTime Manipulation
In JavaScript, a time stamp is the number of milliseconds that have passed since January 1, 1970. If you don't intend to support...
Read more >
Date - JavaScript - MDN Web Docs - Mozilla
Parses a string representation of a date and returns the number of milliseconds since 1 January, 1970, 00:00:00 UTC, with leap seconds ignored....
Read more >
A Complete Guide to JavaScript Dates (and why your ...
This method returns a native Date value — the number of milliseconds since midnight, Jan 1st 1970 UTC, so we need to pass...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found