При использовании amp-date-picker
и его использовании для сохранения amp-state
и event.start
, и event.end
возвращаются через 1 день после выбранной даты.
Пример: я выбираю 15.05.2009 - 22.05.2009, возвращается 16.05.2009 - 23.05.2017.
<!doctype html>
<html amp lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
<link rel="canonical" href="test.html" hreflang="en-us">
<script async src="https://cdn.ampproject.org/v0.js"></script>
<script async custom-template="amp-mustache" src="https://cdn.ampproject.org/v0/amp-mustache-0.2.js"></script>
<script async custom-element="amp-bind" src="https://cdn.ampproject.org/v0/amp-bind-0.1.js"></script>
<script async custom-element="amp-date-picker" src="https://cdn.ampproject.org/v0/amp-date-picker-0.1.js"></script>
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
</head>
<body>
<amp-state id="filterState">
<script type="application/json">
{
"dates": -1,
"startDate": -1,
"endDate": -1
}
</script>
</amp-state>
<amp-date-picker type="range" mode="static" height="360" format="MM/DD/YYYY" min="" on="select:AMP.setState({ filterState: { dates: event.dates, startDate: event.start, endDate: event.end } })"></amp-date-picker>
</body>
</html>
AMP.printState()
filterState:
dates: Array(8)
0: {date: "05/16/2019", id: null}
1: {date: "05/17/2019", id: null}
2: {date: "05/18/2019", id: null}
3: {date: "05/19/2019", id: null}
4: {date: "05/20/2019", id: null}
5: {date: "05/21/2019", id: null}
6: {date: "05/22/2019", id: null}
7: {date: "05/23/2019", id: null}
length: 8
endDate: "05/23/2019"
startDate: "05/16/2019"