[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[pdf-devel] Re: time module test cases
From: |
Aleksander Morgado |
Subject: |
[pdf-devel] Re: time module test cases |
Date: |
Mon, 23 Jun 2008 21:48:47 +0200 |
User-agent: |
Thunderbird 2.0.0.14 (Macintosh/20080421) |
Hi Anish,
Let's see how this should work based on what was done in Perl's DateTime:
http://search.cpan.org/dist/DateTime/lib/DateTime.pm#Adding_a_Duration_to_a_Datetime
"DateTime.pm always adds (or subtracts) days, then months, minutes, and
then seconds and nanoseconds. If there are any boundary overflows, these
are normalized at each step."
So we will add Days, Months, Years, and then Hours, Minutes and finally
Seconds, normalizing the range in each step.
1: If i create a time using
time_span_obj.years=1;
time_span_obj.months=12;
time_span_obj.days=31;
time_span_obj.hours=23;
time_span_obj.minutes=59;
time_span_obj.seconds=59;
time_obj=pdf_time_new();
And add it using pdf_time_add_cal_span() then
Resulting time would be 1972-02-02 01:01:00 UTC
Am i correct?
pdf_time_new will initialize the date to:
* 1970/01/01 00:00:00
1> Add days (31)...
* 1970/02/01 00:00:00
2> Add months (12)...
* 1971/02/01 00:00:00
3> Add years (1)...
* 1972/02/01 00:00:00
4> Add hours (23)...
* 1972/02/01 23:00:00
5> Add minutes (59)...
* 1972/02/01 23:59:00
6> Add seconds (59)...
* 1972/02/01 23:59:59
2: If the date is like this 1970:12:31 23:59:59 and if I add span of 1
year,12 months,31 days 23 hours,59 min ,59 seconds
Resulting date should be 1973-02-02 01:01:59
Am i right?
Initial date:
* 1970/12/31 23:59:59
1> Add days (31)...
* 1971/01/31 23:59:59
2> Add months (12)...
* 1972/01/31 23:59:59
3> Add years (1)...
* 1973/01/31 23:59:59
4> Add hours (23)...
* 1973/02/01 22:59:59
5> Add minutes (59)...
* 1973/02/01 23:58:59
6> Add seconds (59)...
* 1973/02/01 23:59:58
3: What if i pass PDF_U32_MAX or PDF_U32_MIN to
time_span_obj.years=PDF_U32_MAX and add some time span to it , is it a
valid test case?
Err... i would say that you should never pass PDF_U32_MAX to the time
span in any field... but anyway, we could treat it as infinite, in the
way that if time_span_obj.years=PDF_U32_MAX and we add any time span to
it, it will remain being PDF_U32_MAX. I guess we don't have any problem
with PDF_U32_MIN, as it is 0 :-)
Cheers!
-Aleksander