Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007
Getting Current Day/Time etc. by Sam Asghari
Created By: Sam Asghari
Oftentimes you'll want to retrieve and store the current day or current time of something that is being done (for our class project, we needed a day and time that a patients' medical record was created.) After some excruciating searching, the following was found to work:
dAndT := Date dateAndTimeNow "dAndT now corresponds to #(December 2, 2009 10:08:46 am)"
We see d is now an immutable array with 2 elements. Each index in the array corresponds to:
- Date (Month Day, Year)
- Time (Hours:Minutes:Seconds am/pm)
Thus, to automatically retrieve the entire date we can use the following code:
date := dAndT at: 1
And if we wanted to know what day of the month our date contained we could very easily do that. It is also very easy to figure out how many days are in the month given a current day.
date dayOfMonth "this would return the number 2 for the working example on this page"
date daysInMonth "this would return 31, which is the correct number of days in the month of December as per the example"
Alternatively, built-in functions can be used with time as well. If, for example we wanted to know only the hour at which our record was created the following code would be used
time := dAndT at: 2 "gets the time object from our array"
time hours "returns the hour field from the time object. In the example being used here, 10 is returned
Links to this Page
- Cases last edited on 30 July 2011 at 2:33 am by r59h132.res.gatech.edu
- Index of Individual Cases last edited on 3 May 2011 at 12:46 pm by r52h48.res.gatech.edu
- Most Helpful Cases last edited on 11 December 2010 at 4:57 pm by res-128-61-90-36.res.gatech.edu