Skip to content

Conversation

@JackStouffer
Copy link
Contributor

Many people have remarked that std.datetime is confusing: https://github.com/wilzbach/state-of-d-2018/blob/master/12h:%20Which%20parts%20of%20Phobos%20(D%27s%20Standard%20Library)%2C%20if%20any%2C%20do%20you%20find%20difficult%20to%20work%20with%3F

This is the first step to improving that situation.

This PR:

  1. Gives links to symbols based on usage in a clear table
  2. Adds the most common usage of datetime in examples
  3. Removes a large amount of text that is repeated elsewhere. I believe this text was either self-explanitory or gone over on each of the respective function docs

@dlang-bot
Copy link
Contributor

Thanks for your pull request, @JackStouffer!

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub fetch digger
dub run digger -- build "master + phobos#6356"

@JackStouffer
Copy link
Contributor Author

This is just another step along the way to making std.datetime more accessible. I also want to add top level examples to all datetime modules to quickly introduce the concepts of the module.

Copy link
Contributor

@wilzbach wilzbach left a comment

Choose a reason for hiding this comment

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

Nice! I never liked this huge wall of text.
Waiting for @jmdavis's approval though.

import std.datetime.timezone : UTC;
import core.time : days;

auto st = SysTime(DateTime(2018, 1, 1, 12, 30, 10), UTC());
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe use an actual TimeZone here, s.t. it's non-trivial?

Copy link
Member

Choose a reason for hiding this comment

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

UTC is a TimeZone.

@wilzbach
Copy link
Contributor

Haha ironically auto-tester is running in a spurious failure in std.datetime in this PR on FreeBSD:

timelimit: sending warning signal 15
gmake[1]: *** [posix.mak:380: unittest/std/datetime/systime.run] Error 143

https://auto-tester.puremagic.com/show-run.ghtml?projectid=1&runid=3094297&isPull=true

@JackStouffer
Copy link
Contributor Author

This functionality is separated into the following modules
$(UL
$(LI $(MREF std, datetime, date))
Copy link
Contributor

Choose a reason for hiding this comment

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

You need to use _datetime here. While opt-out of automatic keyword highlighting is available since 2.079, it hasn't been applied to dlang.org yet:

https://dlang.org/changelog/2.079.0.html#fix18361

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's turn the switch -> dlang/dlang.org#2307

Copy link
Member

@jmdavis jmdavis left a comment

Choose a reason for hiding this comment

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

I don't know. I can't say that I particularly like these changes. Turning some of the information into a table is definitely an improvement, but a lot of information is lost here. It does need to be rewritten on some level, with some of it being in the specific modules and some of it being here, but throwing it all out seems like a terrible idea to me. However, I can't really direct anyone on how to rewrite it. I'm just going to have to find the time to do it myself. Maybe it's better to let these changes through (with a few tweaks) and have the information here be butchered until I'm able to improve it, but I don't know.

$(LREF StopWatch))
$(LI Benchmarking functions.)
$(LI Various helper functions.)
Phobos provides the following functionality for time:
Copy link
Member

Choose a reason for hiding this comment

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

dates and times

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is referring to time the concept and not time on the clock.

$(TR
$(TD Intervals of Time)
$(TD
$(REF_ALTTEXT Interval, Interval, std, _datetime, interval)$(NBSP)
Copy link
Member

Choose a reason for hiding this comment

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

If you're trying to list the various types, even if you don't care about the range types in the module, there is also PosInfInterval and NegInfInterval.

import std.datetime.timezone : UTC;
import core.time : days;

auto st = SysTime(DateTime(2018, 1, 1, 12, 30, 10), UTC());
Copy link
Member

Choose a reason for hiding this comment

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

UTC is a TimeZone.


auto st = SysTime(DateTime(2018, 1, 1, 12, 30, 10), UTC());
assert(st.toISOExtString() == "2018-01-01T12:30:10Z");
st += 2.days;
Copy link
Member

Choose a reason for hiding this comment

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

I confess that I hate this syntax and would much prefer days(2), though some folks do seem to really like that syntax.

)
)
$(TR
$(TD Durations of Time)
Copy link
Member

Choose a reason for hiding this comment

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

I don't know about these. They're all in core.time, not std.datetime, though they're used quite heavily in std.datetime. So, on the one hand, it's kind of odd to list things, and on the other hand, it does make some sense. If they're going to be listed though, then there should also be a section for the monotonic time listing core.time.MonoTime.

@JackStouffer
Copy link
Contributor Author

I don't think much information is lost. A lot of what's written here is covered in the documentation for the modules and for the types.

@n8sh
Copy link
Member

n8sh commented Mar 30, 2018

I don't think much information is lost. A lot of what's written here is covered in the documentation for the modules and for the types.

The only thing that leaps out to me as needing module-level explanation is a table of accepted time unit strings. (For ease of learning units probably should have been an enumerated type rather than raw strings, but documentation is for what exists.)

@JackStouffer
Copy link
Contributor Author

The only thing that leaps out to me as needing module-level explanation is a table of accepted time unit strings.

I think that would go on the individual module docs.

@jmdavis Ping.

$(TR
$(TD Points in Time)
$(TD
$(REF_ALTTEXT Date, Date, std, _datetime, date)$(NBSP)
Copy link
Contributor

Choose a reason for hiding this comment

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

Preventing auto-highlighting is no longer needed :)
see e.g. dlang/dlang.org#2307

$(LI $(MREF std, _datetime, timezone))
$(LI $(MREF std, _datetime, systime))
$(LI $(MREF std, _datetime, interval))
$(LI $(MREF std, _datetime, stopwatch))
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe add a short, one-line description of each of these packages, s.t. the user knows what the difference betwen date and systime is?

@jmdavis
Copy link
Member

jmdavis commented Apr 4, 2018

I don't think much information is lost. A lot of what's written here is covered in the documentation for the modules and for the types.

Some of the information that was here should be in the package documentation as part of an overview, and some if really just belongs in the modules. The result of these changes is that we pretty much just end up with a table listing the types and a distinct lack of any kind of explanation.

I guess that I'll let Seb merge this when his requested changes are done, but pretty the only way that I'm going to be happy with this is if I take the time to go over the module documentation for each module in std.datetime (including package.d) and rework it. In the interim, at least these changes get rid of the reference to std.datetime being a module, and the table cleans up what information is kept even if just about everything else is lost in the process. Unfortunately, I simply don't have the time to spend on reworking the docs right now. I guess that I'll try to tackle that during dconf.

@dlang-bot dlang-bot merged commit 0d45880 into dlang:master Apr 5, 2018
@JackStouffer JackStouffer deleted the datetime-docs branch April 5, 2018 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants