pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
need to update TimestampUtils code
4+ messages / 3 participants
[nested] [flat]

* need to update TimestampUtils code
@ 2007-01-04 19:28  Do, Leon (Leon) <leondo@alcatel-lucent.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Do, Leon (Leon) @ 2007-01-04 19:28 UTC (permalink / raw)
  To: pgsql-jdbc

Hi,

 

Can someone help me to update this small block of code (see BEGIN and
END block) in the TimestampUtils class or tell me the direction to do
it?  The code allow the util to parse the timezone in both format hhmm
or hh:mm.   

 

            // Possibly read timezone.

            sep = charAt(s, start);

            if (sep == '-' || sep == '+') {

                int tzsign = (sep == '-') ? -1 : 1;

                int tzhr, tzmin;

    

                end = firstNonDigit(s, start+1);    // Skip +/-

 

                //CHANGES BEGIN

                //if 4 digits together

                if (end - (start+1) > 2) {

                    //get first 2 digits as tzhr

                    tzhr = number(s,start+1,start+1+2);

                    // get the rest of digits as tzmin

                    tzmin= number(s,start+1+2, end);

                    start=end;

                } else {

                //CHANGES END

 

                    tzhr = number(s, start+1, end);

                    start = end;

 

                    sep = charAt(s, start);

                    if (sep == ':') {

                        end = firstNonDigit(s, start+1);  // Skip ':'

                        tzmin = number(s, start+1, end);

                        start = end;

                    } else {

                        tzmin = 0;

                    }

                }

               

                // Setting offset does not seem to work correctly in all

                // cases.. So get a fresh calendar for a synthetic
timezone

                // instead

                result.tz = getCalendar(tzsign, tzhr, tzmin);

 

                start = skipWhitespace(s, start);  // Skip trailing
whitespace

            }

 

 

thanks

 

 

Leon Do

Lucent Technologies

Mobility Software Engineer

 

 

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: need to update TimestampUtils code
@ 2007-01-04 21:26  Dave Cramer <pg@fastcrypt.com>
  parent: Do, Leon (Leon) <leondo@alcatel-lucent.com>
  0 siblings, 2 replies; 4+ messages in thread

From: Dave Cramer @ 2007-01-04 21:26 UTC (permalink / raw)
  To: Do, Leon (Leon) <leondo@alcatel-lucent.com>; +Cc: pgsql-jdbc

Does the server ever send us hhmm without a colon ?

Or what is the use case for this.

Either way you need to send us a context diff

Dave
On 4-Jan-07, at 2:28 PM, Do, Leon (Leon) wrote:

> Hi,
>
>
>
> Can someone help me to update this small block of code (see BEGIN  
> and END block) in the TimestampUtils class or tell me the direction  
> to do it?  The code allow the util to parse the timezone in both  
> format hhmm or hh:mm.
>
>
>
>             // Possibly read timezone.
>
>             sep = charAt(s, start);
>
>             if (sep == '-' || sep == '+') {
>
>                 int tzsign = (sep == '-') ? -1 : 1;
>
>                 int tzhr, tzmin;
>
>
>
>                 end = firstNonDigit(s, start+1);    // Skip +/-
>
>
>
>                 //CHANGES BEGIN
>
>                 //if 4 digits together
>
>                 if (end - (start+1) > 2) {
>
>                     //get first 2 digits as tzhr
>
>                     tzhr = number(s,start+1,start+1+2);
>
>                     // get the rest of digits as tzmin
>
>                     tzmin= number(s,start+1+2, end);
>
>                     start=end;
>
>                 } else {
>
>                 //CHANGES END
>
>
>
>                     tzhr = number(s, start+1, end);
>
>                     start = end;
>
>
>
>                     sep = charAt(s, start);
>
>                     if (sep == ':') {
>
>                         end = firstNonDigit(s, start+1);  // Skip ':'
>
>                         tzmin = number(s, start+1, end);
>
>                         start = end;
>
>                     } else {
>
>                         tzmin = 0;
>
>                     }
>
>                 }
>
>
>
>                 // Setting offset does not seem to work correctly  
> in all
>
>                 // cases.. So get a fresh calendar for a synthetic  
> timezone
>
>                 // instead
>
>                 result.tz = getCalendar(tzsign, tzhr, tzmin);
>
>
>
>                 start = skipWhitespace(s, start);  // Skip trailing  
> whitespace
>
>             }
>
>
>
>
>
> thanks
>
>
>
>
>
> Leon Do
>
> Lucent Technologies
>
> Mobility Software Engineer
>
>
>
>
>
>

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: need to update TimestampUtils code
@ 2007-01-04 21:33  Kris Jurka <books@ejurka.com>
  parent: Dave Cramer <pg@fastcrypt.com>
  1 sibling, 0 replies; 4+ messages in thread

From: Kris Jurka @ 2007-01-04 21:33 UTC (permalink / raw)
  To: Dave Cramer <pg@fastcrypt.com>; +Cc: Do, Leon (Leon) <leondo@alcatel-lucent.com>; pgsql-jdbc



On Thu, 4 Jan 2007, Dave Cramer wrote:

> Does the server ever send us hhmm without a colon ?
>
> Or what is the use case for this.

There was previous discussion of this in November and for the purposes of 
updatable ResultSets it is important that we can parse what we generate. 
The solution Oliver suggested (which makes more sense to me than this) is 
to adjust our timestamp generation code to always include a colon.

Kris Jurka



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: need to update TimestampUtils code
@ 2007-01-05 15:47  Do, Leon (Leon) <leondo@alcatel-lucent.com>
  parent: Dave Cramer <pg@fastcrypt.com>
  1 sibling, 0 replies; 4+ messages in thread

From: Do, Leon \(Leon\) @ 2007-01-05 15:47 UTC (permalink / raw)
  To: Dave Cramer <pg@fastcrypt.com>; +Cc: pgsql-jdbc

________________________________

From: Dave Cramer [mailto:pg@fastcrypt.com] 
Sent: Thursday, January 04, 2007 4:26 PM
To: Do, Leon (Leon)
Cc: pgsql-jdbc@postgresql.org
Subject: Re: [JDBC] need to update TimestampUtils code

Does the server ever send us hhmm without a colon ?

	Leon-No, but it is a valid ISO8601 format

	 
	

	Or what is the use case for this.

	Leon-I have some other uses of the class not just the interface
between the server and client.  Having supporting both formats will be
useful a lot.
	

	Either way you need to send us a context diff 

	Leon-attached are the modified file and the diff.txt file.  I
don't know that is what you are looking for.

	

	thanks

	

	Leon Do

Attachments:

  TimestampUtils.java (application/octet-stream, 20.1K) download

diff.txt (text/plain, 1.2K) download 194,201c194,200 < tzhr = number(s, start+1, end); < start = end; < < sep = charAt(s, start); < if (sep == ':') { < end = firstNonDigit(s, start+1); // Skip ':' < tzmin = number(s, start+1, end); < start = end; --- > //if 4 digits together > if (end - (start+1) > 2) { > //get first 2 digits as tzhr > tzhr = number(s,start+1,start+1+2); > // get the rest of digits as tzmin > tzmin= number(s,start+1+2, end); > start=end; 203c202,212 < tzmin = 0; --- > tzhr = number(s, start+1, end); > start = end; > > sep = charAt(s, start); > if (sep == ':') { > end = firstNonDigit(s, start+1); // Skip ':' > tzmin = number(s, start+1, end); > start = end; > } else { > tzmin = 0; > } 231a241 > nfe.printStackTrace();
^ permalink raw reply [nested|flat] 4+ messages in thread


end of thread, other threads:[~2007-01-05 15:47 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-01-04 19:28 need to update TimestampUtils code Do, Leon (Leon) <leondo@alcatel-lucent.com>
2007-01-04 21:26 ` Dave Cramer <pg@fastcrypt.com>
2007-01-04 21:33   ` Kris Jurka <books@ejurka.com>
2007-01-05 15:47   ` Do, Leon (Leon) <leondo@alcatel-lucent.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox