[time-duration] Implement time-duration concept and time-keeper concept exercise#3127
[time-duration] Implement time-duration concept and time-keeper concept exercise#3127thibault2705 wants to merge 3 commits intoexercism:mainfrom
Conversation
|
Hello. Thanks for opening a PR on Exercism 🙂 We ask that all changes to Exercism are discussed on our Community Forum before being opened on GitHub. To enforce this, we automatically close all PRs that are submitted. That doesn't mean your PR is rejected but that we want the initial discussion about it to happen on our forum where a wide range of key contributors across the Exercism ecosystem can weigh in. You can use this link to copy this into a new topic on the forum. If we decide the PR is appropriate, we'll reopen it and continue with it, so please don't delete your local branch. If you're interested in learning more about this auto-responder, please read this blog post. Note: If this PR has been pre-approved, please link back to this PR on the forum thread and a maintainer or staff member will reopen it. |
IsaacG
left a comment
There was a problem hiding this comment.
Please discuss/explain concepts in English and not just with code examples
Please fix
- newlines at the end of files
- blank lines prior to codeblocks and list.
- the HINTS format is not consistent with other HINTS files
- include the complete sample story in the exercise
- the examples in the instructions need to make the task clear
- No smart quotes
- Tests should all use a test table with ideally at least three cases
| @@ -0,0 +1,7 @@ | |||
| { | |||
| "blurb": "Learn how concept time and duration is implemented in Go.", | |||
| @@ -0,0 +1,94 @@ | |||
| # About | |||
|
|
|||
| In Go, time-based calculations are handled using the [`time`][time-package] package. | |||
There was a problem hiding this comment.
| In Go, time-based calculations are handled using the [`time`][time-package] package. | |
| In Go, time-based calculations are handled using the [`time`][time-package] package. |
Make sure there's no double spaces or trailing spaces in any of the files, please.
| - [`time.Time`][time]: represents a specific moment in time (a timestamp) | ||
| - [`time.Duration`][duration]: represents the amount of time elapsed between two moments | ||
|
|
||
| --- |
There was a problem hiding this comment.
Please remove all of these. They're not helpful for formatting.
|
|
||
| ## `time.Time` vs `time.Duration` | ||
|
|
||
| A `time.Time` represents an absolute point in time, such as: |
There was a problem hiding this comment.
These examples don't illustrate the concept of what a point of time is vs a duration. The code could be helpful but you're introducing a new concept; the prose should explain the concept.
| ``` | ||
|
|
||
| In short: | ||
| - `time.Time` → “when something happens” |
| // => 1h5m19.234s | ||
| ``` | ||
|
|
||
| ## 2. Handle timestamps from different time zones |
There was a problem hiding this comment.
How is this different from the first task? Is this concept discussed?
There was a problem hiding this comment.
I agree. Since time.Time is zone-aware and handles the UTC conversion internally, the math is identical. I’ll refactor Task 2 to call the Task 1 method to keep the logic centralized.
There was a problem hiding this comment.
If task 2 calls task 1 ... what is the purpose of task 2?
|
|
||
| Implement the function `GetDurationInDifferentTimezones(start, finish)` that returns the correct duration regardless of time zone differences. | ||
| ```go | ||
| duration := GetDurationInDifferentTimezones(start, finish) |
There was a problem hiding this comment.
This example doesn't illustrate the case
| Implement the function `ParseRun(input)` that converts this string into a duration. | ||
| ```go | ||
| duration, _ := ParseRun("10h5m19.234s") | ||
| // => 10h5m19.234s |
There was a problem hiding this comment.
This example doesn't illustrate the task
There was a problem hiding this comment.
Correct me if I'm wrong, do you mean this task should parse the string to time.Time instead of time.Duration?
There was a problem hiding this comment.
I'm saying this example shows a function that takes "10h5m19.234s" and returns the exact same thing. Based on this example, I would implement it as such:
func ParseRun(s string) (string, error) {
return s, nil
}Is the reader supposed to understand something different from this example? What is the reader supposed to take away here? What does this example show?
| // => "1h5m19.234s +4.843" | ||
| ``` | ||
|
|
||
| ## Notes |
| "time" | ||
| ) | ||
|
|
||
| // GetDuration - Get the difference between start and finish. |
There was a problem hiding this comment.
The doc comment style is not idiomatic
This PR solves the ticket Implement new Concept Exercise: time-duration #1391
, including:
time-durationtime-keeper