给定UTC日期,您如何正确设置“自适应卡-日期选择器”的值?

问题描述

这是卡模板:

{
    "type": "AdaptiveCard","body": [
        {
            "type": "FactSet","facts": [
                {
                    "title": "Given Date 1","value": "${string(dueDate)}"
                },{
                    "title": "Formatted Date 1","value": "{{DATE(${string(dueDate)},COMPACT)}}"
                },{
                    "title": "Given Date 2","value": "${dueDateTicks}"
                },{
                    "title": "Formatted Date 2","value": "${formatTicks(int(dueDateTicks),'yyyy-MM-dd')}"
                }
            ]
        },{
            "type": "Input.Date","id": "date","value": "${formatDateTime(dueDate,'yyyy-MM-dd')}"
        }
    ],"$schema": "http://adaptivecards.io/schemas/adaptive-card.json","version": "1.2"
}

这是给定数据的示例:

{
    "dueDate": "2020-11-30T21:00:00Z","dueDateTicks": "637423668000000000"
}

在设计器预览中尝试此操作时,它可以正确呈现(本地@ GMT + 8):2020-12-01

Given Date 1
2020-11-30T21:00:00Z
Formatted Date 1
12/1/2020

Given Date 2
637423668000000000
Formatted Date 2
2020-12-01

DatePicker Value
12/01/2020

see here

但是在团队中,日期选择器和格式化的日期值已关闭(本地@ GMT + 8):2020-11-30

Given Date 1
11/30/2020 21:00:00
Formatted Date 1
12/1/2020

Given Date 2
637423668000000000
Formatted Date 2
2020-11-30

DatePicker Value
30 Nov 2020

see here

解决方法

Activity类具有一个“ LocalTimestamp”字段,您应使用该字段根据用户的语言环境实例化日期。有关更多信息,请参见here。显然,处理这个问题是特定于平台的(您还没有说您使用的平台),但是例如对于C#,您可以通过DateTimeOffset来处理它。

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...