Problem with time.month

General help: new users, installing the Ecere SDK, using the IDE to compile and run applications.
Post Reply
richard567
Posts: 11
Joined: Sun Feb 20, 2011 3:04 pm

Problem with time.month

Post by richard567 »

Hi All,

I am having a problem with time.month returning a value of 1 rather than the current system clock month. All other time values are returning correctly including time.year; time.day; time.hour; time.minute; and time.second. I have a feeling it is returning an error value of 1 rather than the current system clock month. At one point during compiling, I thought I received a message regarding compatibility or something with Ecere but I am not sure. I don't seem to be able to re-create the error message. Any idea what is causing this? Here is the section of code:

Code: Select all

 
// These two lines are in the same OnRedraw module as the problem code
      DateTime time;
      time.GetLocalTime();
 
// This is the problem section only with time.month
    spa.year          = time.year;
    spa.month         = input11;  // This is my current work-around 
//    spa.month         = 3;
//    spa.month         = time.month; // This is the line returning a value of 1
    spa.day           = time.day;
    spa.hour          = time.hour;
    spa.minute        = time.minute;
    spa.second        = time.second;
// The other time values return correctly and are in full use within the code
 
I have included a temporary work-around in my code for this time.month problem but it would be nice to figure out what is causing this. Currently the user has to enter the current month.

My personal project mentioned in the following post/link is substantially up and running:

http://www.ecere.com/forums/viewtopic.php?f=2&t=135

Thanks for all previous help from Jerome. Once I was able to get a calculated value to display, it made things much easier because then I could tell immediately if I was doing something wrong. It would probably be an easy project for a seasoned programmer but it was a challenge for this amateur. I have just minor work left including the time.month problem mentioned above but it is up and fully functioning.

Thanks again for all previous help and thanks in advance if somebody can help me with the problem mentioned above.

Richard
richard567
Posts: 11
Joined: Sun Feb 20, 2011 3:04 pm

Re: Problem with time.month

Post by richard567 »

Okay. I'm starting to feel like an idiot. Can somebody just verify that I am correct on the following:

time.month returns a cardinal number 0-11 as months since January. To use a value from system time corresponding to March, I need to use (time.month + 1) and same for all the other months?

Thanks in advance.

Richard
jerome
Site Admin
Posts: 608
Joined: Sat Jan 16, 2010 11:16 pm

Re: Problem with time.month

Post by jerome »

Richard,

That's correct, the months are returned between 0 and 11, as is customary in UNIX APIs.
(e.g. http://linux.die.net/man/3/gmtime_r)

The Month data type is an eC enumeration:

public enum Month { january, february, march, april, may, june, july, august, september, october, november, december };

So its possible values really are from january to december, not 0 - 11.
That is probably what the conversion warning or error you saw was about, it was warning you against assigning an int to a Month.

So yes, you need to add +1 (or subtract) as appropriate for a numeric month representation.

Congratulations on getting your program running!
I guess it was a good learning experience, and it's a good thing I was too busy to do it all for you :D

Regards,

Jerome
richard567
Posts: 11
Joined: Sun Feb 20, 2011 3:04 pm

Re: Problem with time.month

Post by richard567 »

Thanks Jerome. A screen shot of my finished product can be viewed below:

Image

Updated 03-03-2011 with minor enhancements to finished product.
Updated 03-15-2011 with more minor enhancements to finished product.

You were a great help as you pointed me in the right direction where I needed further study. You also provided a few tidbits that I was not aware of which helped speed things up. Yes, I actually wanted to do as much of it myself as possible for learning purposes, however, sometimes a little helping hand is a good thing also.

I think I need to rest my brain for a while. I will probably post at some later time with some more questions regarding the Ecere software. So far I only have 043 installed. Meanwhile, I shall be lurking off and on as time allows.

Thanks again for your help.

Richard
Last edited by richard567 on Tue Mar 15, 2011 7:22 pm, edited 6 times in total.
redj
Posts: 105
Joined: Sun Jan 17, 2010 10:03 am

Re: Problem with time.month

Post by redj »

Richard,

Please feel free to post snap shots of Ecere SDK / eC apps directly on the forums.

Cheers,

-redj

PS: hey, webadmin! ;-) That's ok, right? (EDIT)
richard567
Posts: 11
Joined: Sun Feb 20, 2011 3:04 pm

Re: Problem with time.month

Post by richard567 »

Thanks redj. Will do that. I changed the image on 03-03-2011 as I made minor enhancements since the original post.

Richard
Post Reply