QUICK REFERENCE: CLASSES DATE AND TIME

We don't need to create an object for the Class Date. We can use Date like prefix.

Like in the previous lesson, we have some mini-exercices to show all the methods working. Use the Workspace and Transcript windows inside the Squeak-Croquet environment.


dateAndTimeNow

Answer an array whose first element is today and second element is the time. You can read an array element using "at:"

Example

arrDT:= Date dateAndTimeNow.
D:=arrDT at:1.
T:=arrDT at:2.
Transcript show:D.
Transcript show:'------'.
Transcript show:T.

Result

15 November 2004------1:51:41 pm


today

Example

D:= Date today.
Transcript show:D.
 

Result

15 November 2004 


today weekday

Example

wD:= Date  today weekday.
Transcript show:wD.
 

Result

Monday 


today julianDayNumber

Number of days (or part of a day) elapsed since noon GMT on January 1st, 4713 B.C.

Example

jD:= Date  today julianDayNumber.
Transcript show:jD.

Result

2453325


today monthIndex

Example

mI:= Date  today monthIndex.
Transcript show:mI.

Result

11


today weekdayIndex


today monthName


today year


today addDays:n

Date that is n days after today

Example

nD:= Date  today addDays:2.
Transcript show:nD.
   

Result

17 November 2004


today subtractDays:n


today asGregorian.

Return an array of integers #(dd mm yyyy). You can read an array element using "at:"

Example

gD:= Date today asGregorian.
dG:=gD at:1.
Transcript show:dG

Result

15


today asSeconds.

Seconds between 1 January 1901 and the NOW. Useful in creation of timers. Reading the values in 2 moments you can know the interval in seconds.

Example

sN:= Date  today asSeconds.
Transcript show:sN
   

Result

3277929600


today mmddyyy

The usual format:mm/dd/yyyy.

Example

mDY:= Date  today mmddyyyy.
Transcript show:mDY
   

Result

11/15/2004

We don't need to create an object for the Class Time. We can use Time like prefix.


now

Example

|nN| 
nN:= Time  now .
Transcript show:nN
   

Result

3:13:09 pm


now hours

Example

nH:= Time  now hours .
Transcript show:nH
   

Result

15


now minutes


now seconds


PREVIOUS LESSON NEXT LESSON
T. CONTENTS HOMEPAGE

DISCLAIMER: This material can be translated for any language, and reproduced total or partially by anybody using any type of media. But, please, don't put your name like author. And let me know if it was useful (americo@dmu.com).The use of any code, 3D model or technique published is free and doesn't need to have any reference about this source. The author is not responsible for any damage that the material can cause.