[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Smc-calendar] Re: ചാറ്റ് ച െയ്യുക: Sreejith Nair
From: |
Praveen A |
Subject: |
[Smc-calendar] Re: ചാറ്റ് ച െയ്യുക: Sreejith Nair |
Date: |
Mon, 5 Jan 2009 20:32:55 -0800 |
2009/1/5 Sreejith <address@hidden>:
> I hope this is your HEAD revision:
Yes. I made some more changes.
> When we implement it using a Map (Array), we have 2 issues:
>
> 1) When month = 3, we need to check for LeapYear and chose correct start of
> saka month.
> 2) When month = 1, we cant return Saka[month-1][0] in case 'day' is < start
> of saka month.
>
> I think these two cases should be handled separately. What do you think?
month=KCalendarSystem::month( date );
returns month in Saka. So the special case is when month=1
// In a Leap Year Chaithram starts in March 21
if (KCalendarSystem::isLeapYear(date.year()))
Saka[2][1]=21;
// We need to handle days before Jan 21 separately.
if (month > 1 ) {
if (day > Saka[month-1][1])
return Saka[month-1][0];
return Saka[month-2][0];
}
if (day > Saka[month-1][1])
return Saka[month-1][0];
return Saka[11][0];
>
> 172 int KCalendarSystemIndic::month( const QDate &date ) const
>
> 173 {
>
> 174 int month, day;
>
> 175 // It is based on the table from wikipedia
>
> 176 int Saka[12][2] =
>
> 177 {{11,21},{12,20},{1,
> 22},{2,21},{3,22},{4,22},{5,23},{6,23},{7,23},{8,23},{9,22},{10,22}};
>
> This should be a const array and you need to move it out side the member
> function. Another way is to derive CLASS "KCalendarSystemSaka" from "
> KCalendarSystemIndic" and move tthis array to your class.
Only this function uses it so far. If more functions needs this, we
can move it out.
> 178
>
> 179 month=KCalendarSystem::month( date );
>
> 180 day=KCalendarSystem::day( date );
>
> 181
>
> 182 // In a Leap Year Chaithram starts in March 21
>
> 183
>
> 184 if (KCalendarSystem::isLeapYear(date.year()))
>
> 185 Saka[2][1]=21;
> Why do you want to change the array!. Instead you can decrement and return
> the Saka[2][1] value. It doesn't look good to me.
Why not? This way the same logic works for all months. Less conditions to check.
>
> 186
>
> 187 // We need to handle days before Jan 21 separately.
>
> 188 if (month > 1 ) {
> Here, Lets take the case month = 3,
> Means it is March and it is chithram in saka. Now we need a LeapYear Check
> here.
month is in Saka here. But I'm a bit confused as to which functions
use Saka and which does not. AFAICT month, year and day returns Saka
values. And date object always stores gregorian values. Correct me if
I am wrong here.
> 189 if (day > Saka[month-1][1])
>
> 190 return Saka[month-1][0];
>
> 191 return Saka[month-2][0];
> This logic is fine for leap year. But for non leap year,
> if (day >= (Saka[month-1][1])-1)
> return Saka[month-1][0];
> return Saka[month-2][0];
> 192 }
>
> 193 if (day > Saka[month-1][1])
>
> 194 return Saka[month-1][0];
>
> 195 return Saka[11][0];
>
> 196 }
>
>
> 2009/1/5 Praveen A <address@hidden>
>>
>> da check my latest code in git
>>
>> 2009/1/4 Sreejith Nair <address@hidden>:
>> >
>> > ഈ സന്ദേശങ്ങള്നിങ്ങള്ഓഫ് ലൈനായിരുന്നപ്പോള്അയച്ചതാണ്.
>> > 2:55 AM Sreejith: Daa Ippo tharam.... :-)
>> > ________________________________
>> > 10 മിനിട്ടുകള്
>> > 3:06 AM Sreejith: Daa.. Just look at this...
>> > int Saka[][] = {11,21},{12,20},{1,
>> > 22},{2,21},{3,22},{4,22},{5,23},{6,23},{7,23},{8,23},{9,22},{10,22}};
>> > //[12][2]
>> >
>> >
>> > int KCalendarSystemIndic::month( const QDate &date ) const
>> > {
>> > int month, day;
>> > // It is based on the table from wikipedia
>> >
>> > month=date.month();
>> > day=date.day();
>> >
>> > // first Saka month should be treated separately
>> > if (month == 3)
>> > {
>> > if (date.isLeapYear())
>> > {
>> > if (day >= Saka[month-1][1])
>> > return Saka[month-1][0];
>> > return Saka[month-2][0];
>> > }
>> > if (day >= (Saka[month-1][1])+1)
>> > return Saka[month-1][0];
>> > return Saka[month-2][0];
>> > }
>> >
>> > // Jan
>> > if (month == 1)
>> > {
>> > if (day >= Saka[month-1][1])
>> > return Saka[month-1][0];
>> > return Saka[month-1+12][0];
>> > }
>> >
>> > // Feb and After Mar
>> > if (month == 2 || month > 3) {
>> > if (day >= Saka[month-1][1])
>> > return Saka[month-1][0];
>> > return Saka[month-2][0];
>> > }
>> > }
>> >
>> > 3:07 AM I will come after my tea...
>> > :-)
>> > Urgio??
>>
>>
>>
>> --
>> പ്രവീണ് അരിമ്പ്രത്തൊടിയില്
>> <GPLv2> I know my rights; I want my phone call!
>> <DRM> What use is a phone call, if you are unable to speak?
>> (as seen on /.)
>> Join The DRM Elimination Crew Now!
>> http://fci.wikia.com/wiki/Anti-DRM-Campaign
>
>
--
പ്രവീണ് അരിമ്പ്രത്തൊടിയില്
<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call, if you are unable to speak?
(as seen on /.)
Join The DRM Elimination Crew Now!
http://fci.wikia.com/wiki/Anti-DRM-Campaign
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Smc-calendar] Re: ചാറ്റ് ച െയ്യുക: Sreejith Nair,
Praveen A <=