378 |
378 |
379 When all three components are present, the string should take the form: |
379 When all three components are present, the string should take the form: |
380 |
380 |
381 YYYYMMDD:HHMMSS.MMMMMM |
381 YYYYMMDD:HHMMSS.MMMMMM |
382 |
382 |
383 If omitted, the first component is set to January 1st 0 AD nominal Gregorian. |
383 If omitted, the first component defaults to 1 January, year 0 (nominal Gregorian). |
|
384 This is the base date for TTime, so the result of this method will be the number |
|
385 of microseconds in the time specified by the second and third components. |
|
386 |
384 If either the second or third components are omitted, they are set to zero. |
387 If either the second or third components are omitted, they are set to zero. |
385 |
388 |
386 Notes: |
389 Notes: |
387 |
390 |
388 1. The month and day values are offset from zero. |
391 1. The month and day values are offset from zero. |
1470 return(Time::DaysInMonth(dateTime.Year(),dateTime.Month())); |
1473 return(Time::DaysInMonth(dateTime.Year(),dateTime.Month())); |
1471 } |
1474 } |
1472 |
1475 |
1473 EXPORT_C TDay TTime::DayNoInWeek() const |
1476 EXPORT_C TDay TTime::DayNoInWeek() const |
1474 // |
1477 // |
1475 // 1st January 0AD was a Monday |
1478 // 1st January year 0 was a Monday |
1476 // |
1479 // |
1477 /** |
1480 /** |
1478 Gets the day number within the current week. |
1481 Gets the day number within the current week. |
1479 |
1482 |
1480 This is a value in the range zero to six inclusive, and honours the |
1483 This is a value in the range zero to six inclusive, and honours the |
2478 return(mTab[IsLeapYear(aYear)][aMonth]); |
2481 return(mTab[IsLeapYear(aYear)][aMonth]); |
2479 } |
2482 } |
2480 |
2483 |
2481 EXPORT_C TBool Time::IsLeapYear(TInt aYear) |
2484 EXPORT_C TBool Time::IsLeapYear(TInt aYear) |
2482 // |
2485 // |
2483 // up to and including 1600 leap years were every 4 years,since then leap years are every 4 years unless |
2486 // up to and including 1600 leap years were every 4 years; since then leap years are every 4 years unless |
2484 // the year falls on a century which is not divisible by 4 (ie 1900 wasnt,2000 will be) |
2487 // the year falls on a century which is not divisible by 4 (i.e. 1900 wasn't, 2000 will be) |
2485 // for simplicity define year 0 as a leap year |
2488 // for simplicity define year 0 as a leap year |
2486 // |
2489 // |
2487 /** |
2490 /** |
2488 Tests whether a year is a leap year. |
2491 Tests whether a year is a leap year. |
2489 |
2492 |
2498 return(!(aYear%4)); |
2501 return(!(aYear%4)); |
2499 } |
2502 } |
2500 |
2503 |
2501 EXPORT_C TInt Time::LeapYearsUpTo(TInt aYear) |
2504 EXPORT_C TInt Time::LeapYearsUpTo(TInt aYear) |
2502 // |
2505 // |
2503 // from 0AD to present year according to the rule above |
2506 // from year 0 to specified year according to the rule above |
2504 // |
2507 // |
2505 /** |
2508 /** |
2506 Gets the number of leap years between 0 AD nominal Gregorian and the specified |
2509 Gets the number of leap years between year 0 (nominal Gregorian) and the specified |
2507 year - inclusive. |
2510 year, inclusive. |
|
2511 |
|
2512 The calendar used is nominal Gregorian with astronomical numbering (where |
|
2513 year 2000 = 2000 AD, year 1600 = 1600 AD, year 1 = 1 AD, and so year 0 = |
|
2514 1 BC, year -100 = 101 BC). No days are removed from September 1752 or any |
|
2515 other month. Leap year calculation before 1600 uses the Julian method of |
|
2516 every four years, even for years which are exactly divisible by 100 but not |
|
2517 by 400. Thus leap years include: 1200, 1300, 1400, 1500, 1600 and 2000; |
|
2518 non-leap years include: 1601, 1700, 1800, 1900 and 2100. |
2508 |
2519 |
2509 @param aYear The final year in the range to search. If negative, the function |
2520 @param aYear The final year in the range to search. If negative, the function |
2510 will return a negative number of leap years. |
2521 will return a negative number of leap years. |
2511 |
2522 |
2512 @return The number of leap years between 0 AD nominal Gregorian and aYear. |
2523 @return The number of leap years between year 0 (nominal Gregorian) and aYear. |
2513 */ |
2524 */ |
2514 { |
2525 { |
2515 |
2526 |
2516 if (aYear<=0) |
2527 if (aYear<=0) |
2517 return(aYear/4); |
2528 return(aYear/4); |