Ask a Question related to PERL Miscellaneous, Design and Development.

  1. #1

    Default date sorting module

    Hello
    I just came from cpan, after doing some searches and before I get a module,
    wanted to ask if any one out there knows of a module that takes an array of
    dates and sort them regardless of the date formate.

    thanks


    Sam Guest

  2. Similar Questions and Discussions

    1. Sorting a date column
      Sekhar, I think you have run across a known bug where the order by ignores the table prefix POProjects. and orders by the result column called...
    2. Sorting Hash of Hashes with HEAP module
      Hi, I would like to use the Heap module from CPAN to sort Hash of Hashes by values, keeping track of what pairs of keys belong to what values. ...
    3. Formatting and sorting date
      I have an asp page which displays records from an access table. One of the fields in the table is a date field. The regional settings on the...
    4. Grouping and sorting by date
      If you convert your date without the time in datetime format, sql will take it and put 00:00:00 as the time everywhere. That will make grouping...
    5. Module for sorting (while either reading from or writing to) a FH?
      Michele Dondi <bik.mido@tiscalinet.it> wrote: You might borrow code from the Perl Power Tool's implementation of sort(1): ...
  3. #2

    Default Re: date sorting module

    In article <3f66c9a3$1@news.comindico.com.au>, Sam wrote:
    > Hello
    > I just came from cpan, after doing some searches and before I get a module,
    > wanted to ask if any one out there knows of a module that takes an array of
    > dates and sort them regardless of the date formate.
    If the dates doesn't follow any pattern, how could you sort it?
    Compare for example the US date format with som eof the European
    ones: Does one sort 9/7/2002 before or after 7/10/2002 if one
    doesn't know what format they are on?


    --
    Andreas Kähäri
    Andreas Kahari Guest

  4. #3

    Default Re: date sorting module

    Sam <samj@austarmetro.com.au> wrote:
    > I just came from cpan, after doing some searches and before I get a module,
    > wanted to ask if any one out there knows of a module that takes an array of
    > dates and sort them regardless of the date formate.
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    You can't.


    How can you distinguish between these two formats for instance:

    09-07-2003 # MM-DD-YYY - September 7
    and
    09-07-2003 # DD-MM-YYY - July 9

    ??


    --
    Tad McClellan SGML consulting
    [email]tadmc@augustmail.com[/email] Perl programming
    Fort Worth, Texas
    Tad McClellan Guest

  5. #4

    Default Re: date sorting module

    Hi Sam,

    "Sam" <samj@austarmetro.com.au> wrote in message
    news:3f66c9a3$1@news.comindico.com.au...
    > Hello
    > I just came from cpan, after doing some searches and before I get a
    module,
    > wanted to ask if any one out there knows of a module that takes an array
    of
    > dates and sort them regardless of the date formate.
    This might give you some ideas

    use strict;
    use warnings;
    use DateTime;
    my @new_dates;

    my @dates =("Sat, 19 Jul 2003 15:53:45 -0500","1996-02-03","08-Feb-1998
    14:15:29 GMT");


    foreach my $new_date (@dates) {
    push(@new_dates, DateTime::Format::Mytest->parse_datetime($new_date) );
    }

    print map {$_->datetime(), "\n"} sort @new_dates;



    package DateTime::Format::Mytest;

    use DateTime::Format::HTTP;
    use DateTime::Format::Mail;


    use DateTime::Format::Builder (
    parsers => { parse_datetime => [
    sub { eval { DateTime::Format::HTTP->parse_datetime( $_[1] ) } },
    sub { eval { DateTime::Format::Mail->parse_datetime( $_[1] ) } },
    ] }
    );


    Mothra Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139