It would be great if the DeconstructDate component would not only return year, month, day, hour, minute and second but also the weekday (Mon-Sun = 0-6) and the calendar week of the input date.
(both would maybe need an additional input to define the start-day of the week and the method to calculate the calendar week…)
day_of.gh (8.0 KB)
DateTime dt = (System.DateTime)pvm;
int year = dt.Year;
int idayofyear = dt.DayOfYear;
int lastdayinyear = new System.DateTime(year, 12, 31).DayOfYear;
dayofweek = dt.DayOfWeek;
idayofweek = (int)dayofweek;
dayofyear = idayofyear;
daysleftinyear = lastdayinyear-idayofyear;
(and in case you are wondering what
pvm stands for: it is the abbreviation for the Finnish word
päivämäärä, meaning date)
You should be able to get your other features implemented with the help of the doc
Is Sunday or Monday the first day of the week?
Which week numbering system? ISO/EU? North American, Korea, Japan and others? Middle East/Islamic?
whoa… wasn’t that urgent! Thanks anyway!
You can either wait until hell freezes over for your suggestions to be implemented in standard GH components, find a plugin that does the job or write your own scripted solution. And whoa unto you when you are forced to wander in the API documentation (so-called). That way lies madness.
There was a reason I linked to the DateTime struct doc and closed with
I’m sure that, along with some basic internet search skills anyone can figure out all you need and improve the simple base code.
I guess I am pretty fluent in RhinoCommons by now and could have looked up the System.Datetime myself. Grateful for your post nevertheless, Joseph!
This post was more like a whish (-> ) to the Grasshopper team, hoping that an extra output to the DDate-component would actually be a rather low hanging fruit… (no pressure, @DavidRutten).
The response you received here illustrates and confirms my point. Conventional programming languages offer a standard set of date/time methods and are widely documented. Anyone “with some basic internet search skills” can quickly find those answers and move on. Not so with Grasshopper, low hanging fruit or not, and when forced to use the Rhino APIs, you won’t find answers as easily.