Skip to content

[time-duration] Implement time-duration concept and time-keeper concept exercise#3127

Open
thibault2705 wants to merge 3 commits intoexercism:mainfrom
thibault2705:time-duration
Open

[time-duration] Implement time-duration concept and time-keeper concept exercise#3127
thibault2705 wants to merge 3 commits intoexercism:mainfrom
thibault2705:time-duration

Conversation

@thibault2705
Copy link
Copy Markdown

This PR solves the ticket Implement new Concept Exercise: time-duration #1391
, including:

  • Add new concept time-duration
  • Implement new concept exercise time-keeper

@github-actions
Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Member

@IsaacG IsaacG left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix the grammar here

@@ -0,0 +1,94 @@
# About

In Go, time-based calculations are handled using the [`time`][time-package] package.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

---
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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”
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix these quotes

// => 1h5m19.234s
```

## 2. Handle timestamps from different time zones
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this different from the first task? Is this concept discussed?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example doesn't illustrate the task

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct me if I'm wrong, do you mean this task should parse the string to time.Time instead of time.Duration?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do these notes accomplish?

"time"
)

// GetDuration - Get the difference between start and finish.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The doc comment style is not idiomatic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants