卡片模板如下:
{
"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
但在团队中,日期选择器和格式化日期值是off (local @ 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
发布于 2020-09-23 17:44:58
Activity类有一个"LocalTimestamp“字段,您应该使用它来根据用户的区域设置实例化日期。有关详细信息,请参阅here。处理这个问题显然是特定于平台的(您还没有说您在什么平台上),但是对于C#,例如,您可以通过DateTimeOffset来处理这个问题。
https://stackoverflow.com/questions/64032916
复制