www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Day of week from date

reply Joel <joelcnz gmail.com> writes:
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.
Sep 28 2017
next sibling parent reply rikki cattermole <rikki cattermole.co.nz> writes:
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
Sep 28 2017
parent reply Jonathan M Davis <newsgroup.d jmdavisprog.com> writes:
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
Sep 28 2017
parent reply aberba <karabutaworld gmail.com> writes:
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?) ... can confuse you even though their names seems obvious when you're used to.... And then there's secs, mins, etc and those undocumented ones.
Sep 29 2017
parent Jonathan M Davis <newsgroup.d jmdavisprog.com> writes:
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
Sep 29 2017
prev sibling parent Joel <joelcnz gmail.com> writes:
Thanks guys. :-D
Sep 28 2017