projects
/
irspy-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Import isodate() from Utils.pm
[irspy-moved-to-github.git]
/
lib
/
ZOOM
/
IRSpy
/
Utils.pm
diff --git
a/lib/ZOOM/IRSpy/Utils.pm
b/lib/ZOOM/IRSpy/Utils.pm
index
68e23be
..
9f672fe
100644
(file)
--- a/
lib/ZOOM/IRSpy/Utils.pm
+++ b/
lib/ZOOM/IRSpy/Utils.pm
@@
-1,4
+1,4
@@
-# $Id: Utils.pm,v 1.15 2006-11-16 17:18:14 mike Exp $
+# $Id: Utils.pm,v 1.17 2006-11-29 18:15:10 mike Exp $
package ZOOM::IRSpy::Utils;
package ZOOM::IRSpy::Utils;
@@
-7,7
+7,8
@@
use strict;
use warnings;
use Exporter 'import';
use warnings;
use Exporter 'import';
-our @EXPORT_OK = qw(xml_encode
+our @EXPORT_OK = qw(isodate
+ xml_encode
cql_quote
cql_target
irspy_xpath_context
cql_quote
cql_target
irspy_xpath_context
@@
-20,6
+21,14
@@
our $IRSPY_NS = 'http://indexdata.com/irspy/1.0';
# Utility functions follow, exported for use of web UI
# Utility functions follow, exported for use of web UI
+sub isodate {
+ my($time) = @_;
+
+ my($sec, $min, $hour, $mday, $mon, $year) = localtime($time);
+ return sprintf("%04d-%02d-%02dT%02d:%02d:%02d",
+ $year+1900, $mon+1, $mday, $hour, $min, $sec);
+}
+
# I can't -- just can't, can't, can't -- believe that this function
# isn't provided by one of the core XML modules. But the evidence all
# I can't -- just can't, can't, can't -- believe that this function
# isn't provided by one of the core XML modules. But the evidence all
@@
-101,7
+110,7
@@
sub irspy_xpath_context {
sub modify_xml_document {
my($xc, $fieldsByKey, $data) = @_;
sub modify_xml_document {
my($xc, $fieldsByKey, $data) = @_;
- my $nchanges = 0;
+ my @changes = ();
foreach my $key (keys %$data) {
my $value = $data->{$key};
my $ref = $fieldsByKey->{$key} or die "no field '$key'";
foreach my $key (keys %$data) {
my $value = $data->{$key};
my $ref = $fieldsByKey->{$key} or die "no field '$key'";
@@
-115,7
+124,7
@@
sub modify_xml_document {
if ($node->isa("XML::LibXML::Attr")) {
if ($value ne $node->getValue()) {
$node->setValue($value);
if ($node->isa("XML::LibXML::Attr")) {
if ($value ne $node->getValue()) {
$node->setValue($value);
- $nchanges++;
+ push @changes, $ref;
#print "Attr $key: '", $node->getValue(), "' -> '$value' ($xpath)<br/>\n";
}
} elsif ($node->isa("XML::LibXML::Element")) {
#print "Attr $key: '", $node->getValue(), "' -> '$value' ($xpath)<br/>\n";
}
} elsif ($node->isa("XML::LibXML::Element")) {
@@
-140,7
+149,7
@@
sub modify_xml_document {
$node->removeChildNodes();
my $child = new XML::LibXML::Text($value);
$node->appendChild($child);
$node->removeChildNodes();
my $child = new XML::LibXML::Text($value);
$node->appendChild($child);
- $nchanges++;
+ push @changes, $ref;
#print "Elem $key: '$old' -> '$value' ($xpath)<br/>\n";
} else {
warn "unexpected node type $node";
#print "Elem $key: '$old' -> '$value' ($xpath)<br/>\n";
} else {
warn "unexpected node type $node";
@@
-151,11
+160,11
@@
sub modify_xml_document {
my($ppath, $selector) = $xpath =~ /(.*)\/(.*)/;
dom_add_node($xc, $ppath, $selector, $value, @addAfter);
#print "New $key ($xpath) = '$value'<br/>\n";
my($ppath, $selector) = $xpath =~ /(.*)\/(.*)/;
dom_add_node($xc, $ppath, $selector, $value, @addAfter);
#print "New $key ($xpath) = '$value'<br/>\n";
- $nchanges++;
+ push @changes, $ref;
}
}
}
}
- return $nchanges;
+ return @changes;
}
}