[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MirageOS-devel] Unix.tm, CLOCK: date handling in MirageOS



Le lundi, 22 juin 2015 Ã 11:32, Hannes Mehnert a Ãcrit :
> I provided sensible default values for validity times of a X.509
> certificate using Unix.tm/gmtime/time -- all of which are also
> available in the mirage CLOCK module type. Is there a way that the
> X.509 library uses these symbols from the Unix module, and mirage
> takes care that they're available (trivial in the non-xen case, in the
> xen case I believe the OCaml runtime from mirage-xen-ocaml needs to be
> modified slightly!?)?

Why isn't your validation procedure simply a function that takes the various 
components as labelled arguments (see the ASN1 date_to_posix_time function). It 
may be a little bit less inconvenient than passing a Unix.tm record but that 
should do it (and you can have functions directly acting on the records in 
specific backends).  


Le lundi, 22 juin 2015 Ã 15:25, Anil Madhavapeddy a Ãcrit :
> A lightweight time library would be useful.  
I do have a simple calendar library in the works (none of the existing ones 
provide the conceptual view and the "error-proneless" I'd like to have). But 
it's not ready (and calendar time takes time). And I guess people around here 
would prefer that I work on that other thing...


> The missing one here is something that breaks down the time into
> something consumable by a calendar library, and ideally not specifically
> tied to Unix.tm (which requires all the fields to be filled in, often
> with weird offsets in some of the members).

Note that this PR https://github.com/mirage/mirage-clock/pull/2 (which I don't 
think should be merged, as ThomasL mentioned we don't want CLOCKs to have to 
implement calendar things) has everything to do this in pure OCaml and 
thoroughly tested and could be adapted to:  

a) not to give its result with the weird offsets  
b) simply return a recordless (y,m,d) * (hh,mm,ss) value â I guess people do 
not care about wday, which only allows you to specify inconsistant dates.  

So Bos.OS.Time could simply have these two functions pure OCaml functions:

val posix_s_to_date : float -> (int * int * int) * (int * int * int)
val date_to_posix_s : (int * int * int) * (int * int * int) -> float option

I didn't provide them because I thought this would be provided by the 
vapourware calendar library. But if that's only what people need I can provide 
them.  

But does this really help mirage ? Isn't there already too much unixy crap in 
Bos, namely OS.{Path,File,Dir,Cmd} (which only depend on Sys though) ?  

An alternative would be to extract a Bos.OS.Time as an independent module Ptime 
for POSIX time that just provides what Bos.OS.Time provides [1] along with the 
above functions.

Best,

Daniel

[1] http://erratique.ch/software/bos/doc/Bos.OS.Time.html





_______________________________________________
MirageOS-devel mailing list
MirageOS-devel@xxxxxxxxxxxxxxxxxxxx
http://lists.xenproject.org/cgi-bin/mailman/listinfo/mirageos-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.