Re: Nanoseconds in the FAQ.

2003-06-12 Thread Ben Bennett
Please ignore the last one... I biffed it too.  Below is the corrected
POD.

  -ben

=head3 How small an increment of time can I represent?

A can represent nanoseconds.  You can create obects with
that resolution using the C parameter to C or C
and there is a corresponding C accessor.  For these you
give an integer count of the nanoseconds.

A millisecond is a thousandth of a second (10^-3 or 0.001).  The
abbreviation is I.
A microsecond is a millionth of a second (10^-6 or 0.01).  The
abbreviation is I (or more properly Is>).
A nanosecond is a billionth (US) of a second (10^-9 or 0.1).
The abbreviation is I.

=for example begin

  # The ns part is 0.00230 below
  my $dt_ns = DateTime->new(year => 2003, month => 3,   day => 1,
hour => 6,minute => 55, second => 23,
nanosecond => 230);
  print "ns: ", $dt_ns->nanosecond, "\n";  # Prints: "ns: 230\n"

  # Assuming we got milliseconds as an argument
  my $ms = 42;
  my $dt_ms = DateTime->new(year => 2003, month => 3,   day => 1,
hour => 6,minute => 55, second => 23,
nanosecond => $ms * 1_000_000);
  print "ns: ", $dt_ms->nanosecond, "\n";  # Prints: "ns: 4200\n"



=for example end

=for example_testing
  is($_STDOUT_, "ns: 230\nns: 4200\n", "Nanoseconds");


Re: Nanoseconds in the FAQ.

2003-06-12 Thread Ben Bennett
Oops, thanks.  Revised version:

=head3 How small an increment of time can I represent?

A can represent nanoseconds.  You can create obects with
that resolution using the C parameter to C or C
and there is a corresponding C accessor.  For these you
give an integer count of the nanoseconds.

A millisecond is a thousandth of a second (10^-3 or 0.001).  The
abbreviation is I.
A microsecond is a millionth of a second (10^-6 or 0.01).  The
abbreviation is I (or more properly Is>).
A nanosecond is a billionth (US) of a second (10^-9 or 0.1).
The abbreviation is I.

=for example begin

  # The ns part is 0.00230 below
  my $dt_ns = DateTime->new(year => 2003, month => 3,   day => 1,
hour => 6,minute => 55, second => 23,
nanosecond => 230);
  print "ns: ", $dt_ns->nanosecond, "\n";  # Prints: "ns: 230\n"

  # Assuming we got milliseconds as an argument
  my $ms = 42;
  my $dt_ms = DateTime->new(year => 2003, month => 3,   day => 1,
hour => 6,minute => 55, second => 23,
nanosecond => $ms * 1_000_000);
  print "ms: ", $dt_ms->nanosecond, "\n";  # Prints: "ns: 4200\n"



=for example end

=for example_testing
  is($_STDOUT_, "ns: 230\nns: 4200\n", "Nanoseconds");



-ben

On Wed, Jun 11, 2003 at 10:05:02PM -0700, Bruce Van Allen wrote:
> 
> On Wednesday, June 11, 2003, at 07:08  PM, Ben Bennett wrote:
> >I added a section on nanoseconds:
> >The raw POD is below.
> >
> 
> >=head3 How small an increment of time can I represent?
> >
> >A can represent nanoseconds.  You can create obects with
> 
> >=for example begin
> >
> >  # The ns part is 0.00230 below
> >  my $dt_ns = DateTime->new(year => 2003, month => 3,   day => 1,
> >hour => 6,minute => 55, second => 23,
> > nanosecond => 230);
> >  print "ns: ", $dt_ns->nanosecond, "\n";  # Prints: "ns: 230\n"
> >
> >  # Assuming we got microseconds as an argument
>   ^
> I think you meant:milli
> 
> >  my $ms = 42;
> >  my $dt_ms = DateTime->new(year => 2003, month => 3,   day => 1,
> >hour => 6,minute => 55, second => 23,
> > nanosecond => $ms * 1_000_000);
> >  print "ms: ", $dt_ms->nanosecond, "\n";  # Prints: "ms: 4200\n"
>^^
> That number is in nanoseconds (42 milliseconds is 42,000,000 
> nanoseconds); does it make sense to label it 'ms' in the test output?
> 
>   - Bruce
> 
> __bruce__van_allen__santa_cruz__ca__


Re: Nanoseconds in the FAQ.

2003-06-11 Thread Bruce Van Allen
On Wednesday, June 11, 2003, at 07:08  PM, Ben Bennett wrote:
I added a section on nanoseconds:
The raw POD is below.

=head3 How small an increment of time can I represent?

A can represent nanoseconds.  You can create obects with

=for example begin

  # The ns part is 0.00230 below
  my $dt_ns = DateTime->new(year => 2003, month => 3,   day => 1,
hour => 6,minute => 55, second => 23,
nanosecond => 230);
  print "ns: ", $dt_ns->nanosecond, "\n";  # Prints: "ns: 230\n"
  # Assuming we got microseconds as an argument
  ^
I think you meant:milli
  my $ms = 42;
  my $dt_ms = DateTime->new(year => 2003, month => 3,   day => 1,
hour => 6,minute => 55, second => 23,
nanosecond => $ms * 1_000_000);
  print "ms: ", $dt_ms->nanosecond, "\n";  # Prints: "ms: 4200\n"
   ^^
That number is in nanoseconds (42 milliseconds is 42,000,000 
nanoseconds); does it make sense to label it 'ms' in the test output?

  - Bruce

__bruce__van_allen__santa_cruz__ca__



Re: Nanoseconds in the FAQ.

2003-06-11 Thread Iain Truskett
* Ben Bennett ([EMAIL PROTECTED]) [12 Jun 2003 12:09]:

[...]
> I deliberately did not mention fractional_second since Dave suggests
> that it is going away...  If this is not true, please let me know and
> I will add info on it.

It went a few hours ago. All the CVS commit messages sent to the
developer list (it's the only thing the list is used for). You may
find it useful to subscribe to it.

https://lists.sourceforge.net/lists/listinfo/perl-date-time-dev


cheers,
-- 
Iain.


Nanoseconds in the FAQ.

2003-06-11 Thread Ben Bennett
I added a section on nanoseconds:

http://www.limey.net/~fiji/perl/faq.html#2.9%3A%20How%20small%20an%20increment%20of%20time%20can%20I%20represent%3F

The raw POD is below.

I deliberately did not mention fractional_second since Dave suggests
that it is going away...  If this is not true, please let me know and
I will add info on it.

   -ben


=head3 How small an increment of time can I represent?

A can represent nanoseconds.  You can create obects with
that resolution using the C parameter to C or C
and there is a corresponding C accessor.  For these you
give an integer count of the nanoseconds.

A millisecond is a thousandth of a second (10^-3 or 0.001).  The
abbreviation is I.
A microsecond is a millionth of a second (10^-6 or 0.01).  The
abbreviation is I (or more properly Is>).
A nanosecond is a billionth (US) of a second (10^-9 or 0.1).
The abbreviation is I.

=for example begin

  # The ns part is 0.00230 below
  my $dt_ns = DateTime->new(year => 2003, month => 3,   day => 1,
hour => 6,minute => 55, second => 23,
nanosecond => 230);
  print "ns: ", $dt_ns->nanosecond, "\n";  # Prints: "ns: 230\n"

  # Assuming we got microseconds as an argument
  my $ms = 42;
  my $dt_ms = DateTime->new(year => 2003, month => 3,   day => 1,
hour => 6,minute => 55, second => 23,
nanosecond => $ms * 1_000_000);
  print "ms: ", $dt_ms->nanosecond, "\n";  # Prints: "ms: 4200\n"



=for example end

=for example_testing
  is($_STDOUT_, "ns: 230\nms: 4200\n", "Nanoseconds");