Date and time algebra: Difference between revisions

From Cuis CookBook
Jump to navigation Jump to search
(imported material)
 
(syntax hilight)
 
Line 1: Line 1:
'''Problem'''. You want to know what will be the weekday name of the day 1000 day in the future from now.
'''Problem'''. You want to know what will be the weekday name of the day 1000 day in the future from now.


'''Solution'''. Cuis has a class '''Duration''' and is capable of doing dates algebra.
'''Solution'''. Cuis has a class '''Duration''' and is capable of doing dates algebra.<syntaxhighlight lang="smalltalk">
((DateAndTime now) + (Duration days: 1000)) dayOfWeekName . "=> #Saturday "
((DateAndTime now) + (Duration days: 1000)) dayOfWeekName . "=>" #Saturday
</syntaxhighlight>
'''Exercise'''. Explore the classes '''DateAndTime''', '''Duration''' and what is nearby in the Browser.
'''Exercise'''. Explore the classes '''DateAndTime''', '''Duration''' and what is nearby in the Browser.



Latest revision as of 06:55, 13 May 2025

Problem. You want to know what will be the weekday name of the day 1000 day in the future from now.

Solution. Cuis has a class Duration and is capable of doing dates algebra.

((DateAndTime now) + (Duration days: 1000)) dayOfWeekName .      "=>" #Saturday

Exercise. Explore the classes DateAndTime, Duration and what is nearby in the Browser.

Exercise. Find the distance in hours between your birth date and your mother's.