Day of week from date
Jonathan M Davis
newsgroup.d at jmdavisprog.com
Fri Sep 29 03:42:18 UTC 2017
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
More information about the Digitalmars-d-learn
mailing list