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

RE: [Xen-API] [PATCH] Add function to Date module to assert ISO 8601 datetime values are UTC


  • To: 'Anil Madhavapeddy' <anil@xxxxxxxxxx>, Dave Scott <Dave.Scott@xxxxxxxxxxxxx>
  • From: Rob Hoes <Rob.Hoes@xxxxxxxxxx>
  • Date: Thu, 2 Sep 2010 13:29:52 +0100
  • Accept-language: en-US
  • Acceptlanguage: en-US
  • Cc: xen-api <xen-api@xxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Thu, 02 Sep 2010 05:34:13 -0700
  • List-id: Discussion of API issues surrounding Xen <xen-api.lists.xensource.com>
  • Thread-index: ActJ8kIqtQpxQydnS+SXzpba8vG5MwAp9Lag
  • Thread-topic: [Xen-API] [PATCH] Add function to Date module to assert ISO 8601 datetime values are UTC

Ah, thanks for making me aware of that :)

I have attached a new version of the patch.
I now have the function like this:

let assert_utc x =
        try
                Scanf.sscanf x "%_[0-9]T%_[0-9]:%_[0-9]:%_[0-9]Z" ()
        with _ -> invalid_arg x

I think that should do what I wanted.

Cheers,
Rob

> -----Original Message-----
> From: Anil Madhavapeddy [mailto:anil@xxxxxxxxxx]
> Sent: 01 September 2010 17:25
> To: Dave Scott
> Cc: Rob Hoes; xen-api
> Subject: Re: [Xen-API] [PATCH] Add function to Date module to assert
> ISO 8601 datetime values are UTC
> 
> Bits of it aren't threadsafe (although this use might be), but in
> general it definitely isnt.  You could replace this use with a
> Scanf.sscanf easily enough I think?
> 
> -anil
> 
> On 1 Sep 2010, at 17:22, Dave Scott wrote:
> 
> > Hi Rob,
> >
> > Is the Str module threadsafe? ISTR there was something dodgy about it
> in a threaded environment.
> >
> >> +let assert_utc x =
> >> +  let r = Str.regexp "^[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]T[0-
> >> 9][0-9]:[0-9][0-9]:[0-9][0-9]Z$" in
> >> +  if not (Str.string_match r x 0) then
> >> +          invalid_arg x
> >> +
> >
> >
> > Cheers,
> > Dave
> >
> > _______________________________________________
> > xen-api mailing list
> > xen-api@xxxxxxxxxxxxxxxxxxx
> > http://lists.xensource.com/mailman/listinfo/xen-api
> >

Attachment: date-assert-utc
Description: date-assert-utc

_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api

 


Rackspace

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