[MKDoc-commit] [1.6] Methods and templates to make timeranges
easier on the eye
bruno at mkdoc.demon.co.uk
bruno at mkdoc.demon.co.uk
Fri Jan 7 13:25:48 GMT 2005
Log Message:
-----------
[1.6] Methods and templates to make timeranges easier on the eye
Tags:
----
mkdoc-1-6
Modified Files:
--------------
mkd/flo/editor:
TimeRange.pm
mkd/templates/component/headlines:
en.html
mkd/templates/component/timerange:
en.html
Added Files:
-----------
mkd/templates/macros/timerange:
en.html
-------------- next part --------------
Index: TimeRange.pm
===================================================================
RCS file: /var/spool/cvs/mkd/flo/editor/TimeRange.pm,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -Lflo/editor/TimeRange.pm -Lflo/editor/TimeRange.pm -u -r1.1.2.1 -r1.1.2.2
--- flo/editor/TimeRange.pm
+++ flo/editor/TimeRange.pm
@@ -471,6 +471,52 @@
} } DateTime::TimeZone->all_names ];
}
+=item C<< $self->same_day() >>
+
+This method returns true if both the start and end times of the event are on
+the same day and are in the same timezone.
+
+=cut
+
+sub same_day
+{
+ my $self = shift;
+ return 0 unless ($self->{'from_day'} eq $self->{'to_day'});
+ return 0 unless ($self->{'from_month'} eq $self->{'to_month'});
+ return 0 unless ($self->{'from_year'} eq $self->{'to_year'});
+ return 0 unless ($self->{'from_tz'} eq $self->{'to_tz'});
+ return 1;
+}
+
+=item C<< $self->different_year() >>
+
+This method returns true if the start and end times of the event are in
+different years.
+
+=cut
+
+sub different_year
+{
+ my $self = shift;
+ return 0 if ($self->{'from_year'} eq $self->{'to_year'});
+ return 1;
+}
+
+=item C<< $self->same_year_different_day() >>
+
+This method returns true if the start and end times of the event are in
+the same year but on different days.
+
+=cut
+
+sub same_year_different_day
+{
+ my $self = shift;
+ return 0 if $self->different_year;
+ return 0 if $self->same_day;
+ return 1;
+}
+
=item C<< $self->generate_xml() >>
This class overrides generate_xml() in order to update the
Index: en.html
===================================================================
RCS file: /var/spool/cvs/mkd/templates/component/headlines/Attic/en.html,v
retrieving revision 1.1.2.24
retrieving revision 1.1.2.25
diff -Ltemplates/component/headlines/en.html -Ltemplates/component/headlines/en.html -u -r1.1.2.24 -r1.1.2.25
--- templates/component/headlines/en.html
+++ templates/component/headlines/en.html
@@ -14,6 +14,7 @@
align_opposite self/align_opposite;
"
xmlns:petal="http://purl.org/petal/1.0/"
+ xmlns:metal="http://xml.zope.org/namespaces/metal"
>
<h2
xml:lang="en"
@@ -111,32 +112,12 @@
</span>
</dd>
<dd>
- Starts
- <strong
- petal:content="timerange/from_datetime/strftime '%B %e, %Y at %H:%M'"
- >
- DATE
- </strong>
- <strong
- class="time-zone"
- petal:content="timerange/from_datetime/strftime '%Z'"
- >
- TZ
- </strong>
- </dd>
- <dd>
- Ends
- <strong
- petal:content="timerange/to_datetime/strftime '%B %e, %Y at %H:%M'"
- >
- DATE
- </strong>
- <strong
- class="time-zone"
- petal:content="timerange/to_datetime/strftime '%Z'"
- >
- DATE
- </strong>
+ <span
+ metal:use-macro="/macros/timerange/#simple"
+ class="mkdoc-date"
+ >
+ 10:11am to 5:10pm Monday December 18 2005
+ </span>
</dd>
</div>
@@ -239,32 +220,12 @@
</span>
</dd>
<dd>
- Starts
- <strong
- petal:content="timerange/from_datetime/strftime '%B %e, %Y at %H:%M'"
- >
- DATE
- </strong>
- <strong
- class="time-zone"
- petal:content="timerange/from_datetime/strftime '%Z'"
- >
- TZ
- </strong>
- </dd>
- <dd>
- Ends
- <strong
- petal:content="timerange/to_datetime/strftime '%B %e, %Y at %H:%M'"
- >
- DATE
- </strong>
- <strong
- class="time-zone"
- petal:content="timerange/to_datetime/strftime '%Z'"
- >
- DATE
- </strong>
+ <span
+ metal:use-macro="/macros/timerange/#simple"
+ class="mkdoc-date"
+ >
+ 10:11am to 5:10pm Monday December 18 2005
+ </span>
</dd>
</div>
@@ -353,32 +314,12 @@
</span>
</dd>
<dd>
- Starts
- <strong
- petal:content="timerange/from_datetime/strftime '%B %e, %Y at %H:%M'"
- >
- DATE
- </strong>
- <strong
- class="time-zone"
- petal:content="timerange/from_datetime/strftime '%Z'"
- >
- TZ
- </strong>
- </dd>
- <dd>
- Ends
- <strong
- petal:content="timerange/to_datetime/strftime '%B %e, %Y at %H:%M'"
- >
- DATE
- </strong>
- <strong
- class="time-zone"
- petal:content="timerange/to_datetime/strftime '%Z'"
- >
- DATE
- </strong>
+ <span
+ metal:use-macro="/macros/timerange/#simple"
+ class="mkdoc-date"
+ >
+ 10:11am to 5:10pm Monday December 18 2005
+ </span>
</dd>
</div>
Index: en.html
===================================================================
RCS file: /var/spool/cvs/mkd/templates/component/timerange/Attic/en.html,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -Ltemplates/component/timerange/en.html -Ltemplates/component/timerange/en.html -u -r1.1.2.2 -r1.1.2.3
--- templates/component/timerange/en.html
+++ templates/component/timerange/en.html
@@ -7,6 +7,8 @@
<div
class="timerange"
xmlns:petal="http://purl.org/petal/1.0/"
+ xmlns:metal="http://xml.zope.org/namespaces/metal"
+ petal:define="timerange self;"
>
<dl>
<dt
@@ -20,41 +22,13 @@
>
Timerange Title
</dt>
- <dd
- xml:lang="en"
- lang="en"
- dir="ltr"
- >
- Starts
- <strong
- petal:content="self/from_datetime/strftime '%B %e, %Y %H:%M'"
- >
- Start Time
- </strong>
- <strong
- class="time-zone"
- petal:content="self/from_datetime/strftime '%Z'"
- >
- Time Zone
- </strong>
- </dd>
- <dd
- xml:lang="en"
- lang="en"
- dir="ltr"
- >
- Ends
- <strong
- petal:content="self/to_datetime/strftime '%B %e, %Y %H:%M'"
- >
- End Time
- </strong>
- <strong
- class="time-zone"
- petal:content="self/to_datetime/strftime '%Z'"
- >
- Time Zone
- </strong>
+ <dd>
+ <span
+ metal:use-macro="/macros/timerange/#simple"
+ class="mkdoc-date"
+ >
+ 10:11am to 5:10pm Monday December 18 2005
+ </span>
</dd>
</dl>
</div>
--- /dev/null
+++ templates/macros/timerange/en.html
@@ -0,0 +1,65 @@
+<html>
+ <head>
+ <title>
+ Macros for formatting timerange output
+ </title>
+ </head>
+ <body
+ xmlns:petal="http://purl.org/petal/1.0/"
+ xmlns:metal="http://xml.zope.org/namespaces/metal"
+ >
+ <dl>
+ <dt>This item has a title</dt>
+ <dd>
+ <span
+ metal:define-macro="simple"
+ class="mkdoc-date"
+ >
+ <span
+ petal:condition="timerange/same_day"
+ petal:omit-tag=""
+ >
+ <span
+ petal:omit-tag=""
+ petal:content="timerange/from_datetime/strftime '%l:%M%P'"
+ >10:11am</span>
+ to <span
+ petal:omit-tag=""
+ petal:content="timerange/to_datetime/strftime '%l:%M%P'"
+ >10:11am</span>
+ <span
+ petal:omit-tag=""
+ petal:content="timerange/to_datetime/strftime '%A %e %B %Y'"
+ >Monday December 18 2005</span>
+ </span>
+ <span
+ petal:condition="timerange/same_year_different_day"
+ petal:omit-tag=""
+ >
+ <span
+ petal:omit-tag=""
+ petal:content="timerange/from_datetime/strftime '%l:%M%P %A %e %B,'"
+ >12:00pm Monday 18 January,</span>
+ to <span
+ petal:omit-tag=""
+ petal:content="timerange/to_datetime/strftime '%l:%M%P %A %e %B %Y'"
+ >5:00pm Monday 02 February 2005</span>
+ </span>
+ <span
+ petal:condition="timerange/different_year"
+ petal:omit-tag=""
+ >
+ <span
+ petal:omit-tag=""
+ petal:content="timerange/from_datetime/strftime '%l:%M%P %A %e %B %Y,'"
+ >7:00pm Monday 31 December 2004,</span>
+ to <span
+ petal:omit-tag=""
+ petal:content="timerange/to_datetime/strftime '%l:%M%P %A %e %B %Y'"
+ >4:00am Monday 01 January 2005</span>
+ </span>
+ </span>
+ </dd>
+ </dl>
+ </body>
+</html>
More information about the MKDoc-commit
mailing list