Computer Science Canada Determining the time, and date in turing |
Author: | xXInsanityXx [ Sun Nov 27, 2005 8:14 am ] |
Post subject: | Determining the time, and date in turing |
Hello, I was wondering if there is a way to determine the time and date of a PC (The one on the taskbar) in Turing? Please and Thank you |
Author: | Cervantes [ Sun Nov 27, 2005 9:31 am ] |
Post subject: | |
There is. Check out the Time module in the Turing Help manual. |
Author: | xXInsanityXx [ Sun Nov 27, 2005 11:05 am ] | ||
Post subject: | |||
I checked the time module in turing help file, but im still not satified, Time.Date gives out the time and date in this format "27 Nov 05 10:59:37" but what if i want "Nov" in full form "November", do i have to make a bunch of if statements? like:
Or is there a way to simplify it? |
Author: | Cervantes [ Sun Nov 27, 2005 11:23 am ] | ||||||
Post subject: | |||||||
Generally, creating a bunch of if statements is not the way to go about things. A hash would be great for this. But alas, Turing does not support hashes. Well, you can create two arrays:
Better yet, create an array of a record. I'm not exactly sure how the initing goes for this, so I'm just taking a guess:
Then to switch, you'll match the abbreviation with the string you're given, then convert that into a full month name.
|
Author: | MysticVegeta [ Sun Nov 27, 2005 11:30 am ] | ||
Post subject: | |||
Note: Pseudocode!
|
Author: | Cervantes [ Sun Nov 27, 2005 1:09 pm ] | ||
Post subject: | |||
MysticVegeta wrote:
That for loop should only go from 1 to 12. Otherwise, if month is something like "February", your program will crash. |
Author: | MysticVegeta [ Sun Nov 27, 2005 2:22 pm ] |
Post subject: | |
subtract 12 then instead of making 2 arrays. |
Author: | Cervantes [ Sun Nov 27, 2005 2:54 pm ] |
Post subject: | |
I think even two arrays is better than this approach. It more effectively conveys what the arrays are storing. One array containing two different sets of data can confuse people. And the one array of a record is definately the most expressive way to do this, thus far. |