WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-api

RE: [Xen-API] [PATCH] Add function to Date module to assert ISO 8601 dat

To: 'Anil Madhavapeddy' <anil@xxxxxxxxxx>, Dave Scott <Dave.Scott@xxxxxxxxxxxxx>
Subject: RE: [Xen-API] [PATCH] Add function to Date module to assert ISO 8601 datetime values are UTC
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
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <9CBB658E-6C98-4B6C-A4F7-D85733B95FE2@xxxxxxxxxx>
List-help: <mailto:xen-api-request@lists.xensource.com?subject=help>
List-id: Discussion of API issues surrounding Xen <xen-api.lists.xensource.com>
List-post: <mailto:xen-api@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=unsubscribe>
References: <E1OqmkK-00080d-0M@xxxxxxxxxxxxxxxxxxxxxxxx> <81A73678E76EA642801C8F2E4823AD219330C427FF@xxxxxxxxxxxxxxxxxxxxxxxxx> <9CBB658E-6C98-4B6C-A4F7-D85733B95FE2@xxxxxxxxxx>
Sender: xen-api-bounces@xxxxxxxxxxxxxxxxxxx
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