### Re: Patch for DateTime::Format::W3CDTF to respekt second fragment part

```Jonathan Leffler wrote:
Or, what happens if there are 10 digits after the decimal point.

That's what the substr() is for.

Yeah, mostly academic, except I'm working towards a time type (not for
Perl per se) that extends down to picoseconds (and up to 10^12 years,
too).

At least 105 bits, then.  TAI64 covers nearly 10^12 years, of course,
and the extension TAI64NA goes down to attoseconds in a 128-bit format.
What's the concept behind your type?

Personally I like to use bignum rational arithmetic, for unlimited
resolution.  Performance is atrocious with the Perl bignum libraries,
unfortunately.

-zefram

```

### Re: Patch for DateTime::Format::W3CDTF to respekt second fragment part

```Zefram [EMAIL PROTECTED] wrote:
Re: Patch for DateTime::Format::W3CDTF to respekt second fragment part

Julian Haupt wrote:
+if (\$date =~ s/\.(\d+)\$// )
+{
+   my \$fraction = \$1;
+   \$p{'nanosecond'} = (1 / \$fraction) * 10**9;
+}

That inversion can't be right.  Surely you mathematically want

\$p{'nanosecond'} = 0.\$fraction * 10**9;

but actually the nanoseconds member is supposed to be an integer, and
it would be better to avoid floating-point arithmetic entirely:

\$fraction = substr(\$fraction, 0, 9);
\$fraction .= 0 x (9 - length(\$fraction);
\$p{'nanosecond'} = 0 + \$fraction;

Beware the picosecond!

Or, what happens if there are 10 digits after the decimal point.  I've no
idea what -3 zeroes looks like, but the answer is unlikely to be correct.

Yeah, mostly academic, except I'm working towards a time type (not for
Perl per se) that extends down to picoseconds (and up to 10^12 years,
too).

--
Jonathan Leffler ([EMAIL PROTECTED])
STSM, Informix Database Engineering, IBM Information Management Division
4100 Bohannon Drive, Menlo Park, CA 94025-1013
Tel: +1 650-926-6921Tie-Line: 630-6921
I don't suffer from insanity; I enjoy every minute of it!

NB: with effect from 2007-11-28, my address and phone number change to:
4400 N First St, San Jose, CA 95134-1257
Tel: +1 408-956-2436 T/L: 475-2436

smime.p7s
Description: S/MIME Cryptographic Signature

```

### Re: Patch for DateTime::Format::W3CDTF to respekt second fragment part

```Julian Haupt wrote:
+if (\$date =~ s/\.(\d+)\$// )
+{
+  my \$fraction = \$1;
+  \$p{'nanosecond'} = (1 / \$fraction) * 10**9;
+}

That inversion can't be right.  Surely you mathematically want

\$p{'nanosecond'} = 0.\$fraction * 10**9;

but actually the nanoseconds member is supposed to be an integer, and
it would be better to avoid floating-point arithmetic entirely:

\$fraction = substr(\$fraction, 0, 9);
\$fraction .= 0 x (9 - length(\$fraction);
\$p{'nanosecond'} = 0 + \$fraction;

-zefram

```