PageRenderTime 46ms CodeModel.GetById 20ms app.highlight 24ms RepoModel.GetById 1ms app.codeStats 0ms

/XML-FeedPP/t/08_datetime.t

http://xml-treepp.googlecode.com/
Unknown | 114 lines | 114 code | 0 blank | 0 comment | 0 complexity | f309c557f52d2bbfc2a012b2f35ae7c9 MD5 | raw file
  1# ----------------------------------------------------------------
  2    use strict;
  3    use Test::More tests => 50;
  4    BEGIN { use_ok('XML::FeedPP') };
  5# ----------------------------------------------------------------
  6    my $date110u = 1100000000;
  7    my $date110w = "2004-11-09T11:33:20Z";              # 1100000000
  8    my $date110h = "Tue, 09 Nov 2004 11:33:20 GMT";
  9    my $date111w = "2005-03-05T14:20:00+09:00";         # 1110000000
 10    my $date111h = "Sat, 05 Mar 2005 14:20:00 +0900";
 11    my $date112w = "2005-06-29T08:06:30-09:00";         # 1120000000
 12    my $date112h = "Wed, 29 Jun 2005 08:06:30 -0900";
 13    my $date113w = "2005-10-23T01:53:20Z";              # 1130000000
 14    my $date113h = "Sun, 23 Oct 2005 01:53:20 GMT";
 15    my $date114w = "2006-02-15T19:40:00Z";              # 1140000000
 16    my $date114h = "Wed, 15 Feb 2006 19:40:00 GMT";
 17    my $url = "http://www.kawa.net/";
 18# ----------------------------------------------------------------
 19    my $feed1 = XML::FeedPP::RSS->new();
 20    $feed1->pubDate( $date111h );
 21    is( $feed1->pubDate(), $date111w, "RSS:  http - w3cdtf 1" );
 22    $feed1->pubDate( $date112h );
 23    is( $feed1->pubDate(), $date112w, "RSS:  http - w3cdtf 2" );
 24    $feed1->pubDate( $date113w );
 25    is( $feed1->pubDate(), $date113w, "RSS:  w3cdtf - http - w3cdtf 1" );
 26    $feed1->pubDate( $date114w );
 27    is( $feed1->pubDate(), $date114w, "RSS:  w3cdtf - http - w3cdtf 2" );
 28# ----------------------------------------------------------------
 29    my $feed2 = XML::FeedPP::RDF->new();
 30    $feed2->pubDate( $date111h );
 31    is( $feed2->pubDate(), $date111w, "RDF:  http - w3cdtf 1" );
 32    $feed2->pubDate( $date112w );
 33    is( $feed2->pubDate(), $date112w, "RDF:  w3cdtf - w3cdtf 1" );
 34    $feed2->pubDate( $date113h );
 35    is( $feed2->pubDate(), $date113w, "RDF:  http - w3cdtf 2" );
 36    $feed2->pubDate( $date114w );
 37    is( $feed2->pubDate(), $date114w, "RDF:  w3cdtf - w3cdtf 2" );
 38# ----------------------------------------------------------------
 39    my $feed3 = XML::FeedPP::Atom->new();
 40    $feed3->pubDate( $date111w );
 41    is( $feed3->pubDate(), $date111w, "Atom: w3cdtf - w3cdtf 1" );
 42    $feed3->pubDate( $date112h );
 43    is( $feed3->pubDate(), $date112w, "Atom: http - w3cdtf 1" );
 44    $feed3->pubDate( $date113w );
 45    is( $feed3->pubDate(), $date113w, "Atom: w3cdtf - w3cdtf 2" );
 46    $feed3->pubDate( $date114h );
 47    is( $feed3->pubDate(), $date114w, "Atom: http - w3cdtf 2" );
 48# ----------------------------------------------------------------
 49    is( $feed1->get_pubDate_native(),  $date114h, "RSS:  channel native" );
 50    is( $feed2->get_pubDate_native(),  $date114w, "RDF:  channel native" );
 51    is( $feed3->get_pubDate_native(),  $date114w, "Atom: channel native" );
 52    is( $feed1->get_pubDate_w3cdtf(),  $date114w, "RSS:  channel w3cdtf" );
 53    is( $feed2->get_pubDate_w3cdtf(),  $date114w, "RDF:  channel w3cdtf" );
 54    is( $feed3->get_pubDate_w3cdtf(),  $date114w, "Atom: channel w3cdtf" );
 55    is( $feed1->get_pubDate_rfc1123(), $date114h, "RSS:  channel rfc1123" );
 56    is( $feed2->get_pubDate_rfc1123(), $date114h, "RDF:  channel rfc1123" );
 57    is( $feed3->get_pubDate_rfc1123(), $date114h, "Atom: channel rfc1123" );
 58# ----------------------------------------------------------------
 59    $feed1->pubDate( $date110u );
 60    $feed2->pubDate( $date110u );
 61    $feed3->pubDate( $date110u );
 62    is( $feed1->get_pubDate_epoch(), $date110u, "RSS:  channel epoch" );
 63    is( $feed2->get_pubDate_epoch(), $date110u, "RDF:  channel epoch" );
 64    is( $feed3->get_pubDate_epoch(), $date110u, "Atom: channel epoch" );
 65    my $w3c1  = $feed1->get_pubDate_w3cdtf();
 66    my $w3c2  = $feed2->get_pubDate_w3cdtf();
 67    my $w3c3  = $feed3->get_pubDate_w3cdtf();
 68    is( $w3c2, $w3c1, "RSS/RDF:  epoch - w3cdtf" );
 69    is( $w3c3, $w3c1, "RSS/Atom: epoch - w3cdtf" );
 70    my $http1 = $feed1->get_pubDate_rfc1123();
 71    my $http2 = $feed2->get_pubDate_rfc1123();
 72    my $http3 = $feed3->get_pubDate_rfc1123();
 73    is( $http2, $http1, "RSS/RDF:  epoch - http" );
 74    is( $http3, $http1, "RSS/Atom: epoch - http" );
 75# ----------------------------------------------------------------
 76    my $item1 = $feed1->add_item( $url );
 77    my $item2 = $feed2->add_item( $url );
 78    my $item3 = $feed3->add_item( $url );
 79# ----------------------------------------------------------------
 80    $item1->pubDate( $date110u );
 81    $item2->pubDate( $date110u );
 82    $item3->pubDate( $date110u );
 83    is( $item1->get_pubDate_epoch(), $date110u, "RSS:  item epoch" );
 84    is( $item2->get_pubDate_epoch(), $date110u, "RDF:  item epoch" );
 85    is( $item3->get_pubDate_epoch(), $date110u, "Atom: item epoch" );
 86# ----------------------------------------------------------------
 87    $item1->pubDate( $date110h );
 88    $item2->pubDate( $date110h );
 89    $item3->pubDate( $date110h );
 90    is( $item1->pubDate(), $date110w, "RSS:  item http - w3cdtf" );
 91    is( $item2->pubDate(), $date110w, "RDF:  item http - w3cdtf" );
 92    is( $item3->pubDate(), $date110w, "Atom: item http - w3cdtf" );
 93    is( $item1->get_pubDate_native(), $date110h, "RSS:  item native http" );
 94    is( $item2->get_pubDate_native(), $date110w, "RDF:  item native http" );
 95    is( $item3->get_pubDate_native(), $date110w, "Atom: item native http" );
 96    is( $item1->get_pubDate_w3cdtf(), $date110w, "RSS:  item w3cdtf" );
 97    is( $item2->get_pubDate_w3cdtf(), $date110w, "RDF:  item w3cdtf" );
 98    is( $item3->get_pubDate_w3cdtf(), $date110w, "Atom: item w3cdtf" );
 99# ----------------------------------------------------------------
100    $item1->pubDate( $date111w );
101    $item2->pubDate( $date111w );
102    $item3->pubDate( $date111w );
103    is( $item1->pubDate(), $date111w, "RSS:  item http - w3cdtf" );
104    is( $item2->pubDate(), $date111w, "RDF:  item http - w3cdtf" );
105    is( $item3->pubDate(), $date111w, "Atom: item http - w3cdtf" );
106    is( $item1->get_pubDate_native(),  $date111h, "RSS:  item native w3cdtf" );
107    is( $item2->get_pubDate_native(),  $date111w, "RDF:  item native w3cdtf" );
108    is( $item3->get_pubDate_native(),  $date111w, "Atom: item native w3cdtf" );
109    is( $item1->get_pubDate_rfc1123(), $date111h, "RSS:  item rfc1123" );
110    is( $item2->get_pubDate_rfc1123(), $date111h, "RDF:  item rfc1123" );
111    is( $item3->get_pubDate_rfc1123(), $date111h, "Atom: item rfc1123" );
112# ----------------------------------------------------------------
113;1;
114# ----------------------------------------------------------------