Day of week from date

Jonathan M Davis newsgroup.d at jmdavisprog.com
Fri Sep 29 14:51:09 UTC 2017


On Friday, September 29, 2017 14:34:04 aberba via Digitalmars-d-learn wrote:
> On Friday, 29 September 2017 at 03:42:18 UTC, Jonathan M Davis
>
> wrote:
> > On Friday, September 29, 2017 04:32:44 rikki cattermole via
> >
> > Digitalmars-d- learn wrote:
> >> On 29/09/2017 4:25 AM, Joel wrote:
> >> > With a given date, I want to know what day it is (like
> >> > Sunday, Monday,
> >> > etc).
> >> >
> >> > I had a look up on std.datetime, and core.time, but they
> >> > don't seem to have a function for it.
> >>
> >> https://dlang.org/phobos/std_datetime_date.html#.DateTime.dayOfWeek
> >
> > Date and SysTime also have that function. So, whether you're
> > creating one of those types manually - e.g. Date(2012, 7, 19) -
> > or getting it from the system clock - e.g. Clock.currTime() -
> > dayOfWeek will give you the day of the week for that particular
> > object. TimeOfDay is the only time point type in std.datetime
> > that does not have dayOfWeek, but that's because it makes no
> > sense given that it simply represents a time of day.
> >
> > - Jonathan M Davis
>
> The documentation of std.datetime is very confusing at first.
> Monotime, Clock, DateTime, SysTime (deprecated?)

SysTime is not deprecated. If anything, it's the time point type that most
code should be using. Now that std.datetime has been split into separate
modules, it's in std.datetime.systime.

>  ... can confuse
> you even though their names seems obvious when you're used to....

Well, I really don't know how to help you there. The documentation on the
types and functions in there says what they do, and there are examples on
most of the functions.

> And then there's secs, mins, etc and those undocumented ones.

I'm not sure what you're talking about here. AFAIK, everything is
documented. The only missing docs that I'm aware of are some examples that
don't show up on some of the functions due to a compiler bug.

- Jonathan M Davis



More information about the Digitalmars-d-learn mailing list