ampproject / ampproject/amphtml
Negative time in amp-date-countdown
- Dominant language
- JavaScript
- Stars
- 14.9k
- Forks
- 4.1k
- PR merge metrics
- No merged PRs in 30d
Description
### Description
https://amp.dev/documentation/components/amp-date-countdown/ does not clarify what should happen for an amp-date-countdown time that has expired.
In our use case, we had a countdown until the start of October. Now that we are in October, the expectation was that the countdown date would show a value of 0.
Instead, it gives the negative value of time since it expired, at the time the page loaded. Refreshing the page will change the value.
The date-count-up option looks like it's working properly as intended currently, so we may just need another option that can be set to have when-ended="stop" have the value return 0 after the timer has elapsed in the past.
### Reproduction Steps
Using the AMP playground for amp-date-countdown: https://playground.amp.dev/?url=https%3A%2F%2Fpreview.amp.dev%2Fdocumentation%2Fexamples%2Fcomponents%2Famp-date-countdown&format=websites&_gl=1*2cbo5p*_ga*YW1wLV9fMTBORjE2UzRUNXRGZDJSV1Z4S2c.
Add these amp-date-countdown elements that count down until the Y2K issue occurs and see if they behave as expected, and wonder how we should set a stopped clock at 0:
```
Default: {{d}} days, {{h}} hours, {{m}} minutes and {{s}} seconds until Y2K.
Continue: {{d}} days, {{h}} hours, {{m}} minutes and {{s}} seconds until Y2K.
Stop: {{d}} days, {{h}} hours, {{m}} minutes and {{s}} seconds until Y2K.
data-count-up Default: {{d}} days, {{h}} hours, {{m}} minutes and {{s}} seconds until Y2K.
data-count-up Continue: {{d}} days, {{h}} hours, {{m}} minutes and {{s}} seconds until Y2K.
data-count-up Stop: {{d}} days, {{h}} hours, {{m}} minutes and {{s}} seconds until Y2K.
```
### Relevant Logs
_No response_
### Browser(s) Affected
Chrome, Firefox, Safari, Edge, UC Browser
### OS(s) Affected
_No response_
### Device(s) Affected
_No response_
### AMP Version Affected
2109102127000
Contributor guide
Research direction
Start with the amp-date-countdown documentation and reproduce the six cases in the AMP playground using the supplied Y2K end date. Compare the default, continue, stop, and data-count-up behaviors, then determine the expected stopped-clock value and update the component or its documentation accordingly. Done means the expired countdown behavior is explicit and the stop case consistently shows the agreed result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100