[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [pdf-devel] Some thoughts on the time module...
From: |
Aleksander Morgado |
Subject: |
Re: [pdf-devel] Some thoughts on the time module... |
Date: |
Tue, 01 Jul 2008 00:31:29 +0200 |
User-agent: |
Thunderbird 2.0.0.14 (Macintosh/20080421) |
> Could you specify which are the functions needed? The time module is the
> right place to put them.
We'll need something that will take the two DWORDS that windows uses (a high and
a low) and return a pdf_time_t.
That's probably easy to do.
First we must convert file-time to system-time, changing the timescale:
http://msdn.microsoft.com/en-us/library/ms724228(VS.85).aspx
In this way we get a time_t (Unix time).
For the UNIX time, is time_t equivalent to pdf_time_t? If so, then nothing is
needed there, but if they're not then we need something that'll take a time_t
and return a pdf_time_t.
They are equivalent internally, but the pdf_time_t must be used as an
opaque type. The simplest option would be to use a span to set up the
seconds since unix timescale origin, and add it to a newly created
pdf_time_t:
pdf_time_t newtime = pdf_time_new();
pdf_time_span_t newspan = pdf_time_span_new();
/* This will work until 2038... */
pdf_time_span_set_from_i32(&newspan, (pdf_i32_t)time_t);
/* Or using pdf_time_span_set() to set the high dword and
* the low dword) */
/* And finally set the correct date */
pdf_time_add_span(newtime, newspan);
Both functions can be implemented in the pdf_time module.
Yes, maybe could be easier to directly update the API with two new
functions, both passing as argument the number of seconds since unix
timescale origin:
pdf_time_set_from_i32(pdf_time_t time_object,
pdf_i32_t seconds);
pdf_time_set(pdf_time_t time_object, \
pdf_i32_t high, pdf_u32_t low);
Plus maybe an additional one to be used in Windows, which involves also
the timescale change (filetime to systime):
pdf_time_set_from_filetime(pdf_time_t time_object, \
pdf_i32_t high, pdf_u32_t low);
Cheers,
-Aleksander