[pmwiki-users] Date Input - Manipulations Via Forms and Output for Pagelists

Sivakatirswami katir at hindu.org
Tue Jan 2 05:49:29 CST 2007


Note: if you think there is a different way to peel this apple, I'm open to
alternative methods:

Goal: input form allows for entry of "Due-Date", with format constrained
to spec
on a "to do" page which will live as data  on the page that
we can  parse and do page list  booleans against,

AND

  also increment by x Number of x days into  the future by some pick or 
enter
and  submit action...

(I am partial to the international, zero padded
date format YYYY-MM-DD as delivered automatically by SQL
processes, but if that's not available to use in PHP we can
live with alternative date formats) :

e.g. (:input type="text" ....??date input functions here??:)

# not sure how best to set up user input of a date into a form such that
# a particular format is enforced, so as to be consistant and parseable 
later...

so that is Input Question #1.

Goal:  ends up as data, textvar, on the page like this:

(:due_date: 2007-02-15:)
# or some other format if preferred for PHP processing.

# Being a due date of February 15, 2007

OK assuming we have the input process wired nicely then the
next process we will want  is to allow for a  user to increment that date.
All I want is "advance by x number of days" -- keep it simple... we are not
interested in picking dates from a calendar... which is a more complex layer
we do not need...although if it would be easier than advancing by X 
number of days
I would be open to it...(maybe there is a recipe already cooked 
up...that uses a calendar)

example: (general algorithm)
put field: "due_date" into {$DueDate}
put {$DueDate) +10 days into fld "due_date"

and now the form has:

(:due_date: 2007-02-25:) February 25, 2007  # ten days later

So that's Input Question # 2,  advance date by days integer...

Revolution would handle this by  adding 10 days to the day of the month
item in a dateItems formatted date (in case this helps with developing a PHP
handler)

e.g. in Revolution:
on mouseup
   put field "due_date" into tDate # 3/25/07
   convert tDate to dateItems # --> 2007,3,25,2,0,0,1
   add 10 to item 3 of tDate # --> 2007,3,35,2,0,0,5
   convert tDate to  short date  # --> 4/4/07
   put tDate into fld "due_date"
end mouseup

# result: (:due_date: 4/4/07:)

How can I do this on a PMwiki form? I'm using ZAP if that helps.

That's the input side: later on the output side we will need to set up
a page list #format that does

(:if due_date = or < todaysDate #add to page list output:)

so that  page will show

!!!Over Due!
(page list group=TODO* where {=$due_date}<{$TodaysDate} fmt=#overDueList;)

So that will be Output Question #3 -- how to do conditionals against dates.

Syntax is all wrong of course, I'm just getting a handle on PMwiki 
conditionals
and pagelist formats, but, you get the idea.

TIA
Sivakatirswami

documentation on this revolution function is below if it helps to point
to a PMwiki-PHP parallel process, it describes what we want, which will
involve advancing dates  across the month integer boundary (30th or 31st
  to the 1st) "intelligently" i.e. aware of the number of days per month.
Dec 25 + 10 days gets you Jan 4th, but Sep 25 +10 days gets you Oct 5th.

------------
If the dateAndTime is a container, the converted date and time is placed
in the container, replacing the previous contents. If the dateAndTime is
a string, the converted date and time is placed in the it variable.

The dateItems format is a comma-separated list of numbers:
	* the year
	* the month number
	* the day of the month
	* the hour in 24-hour time
	* the minute
	* the second
	* the numeric day of the week where Sunday is day 1, Monday is day 2,
and so forth

The convert command can handle dates in dateItems format where one or
more of the items is out of the normal range. This means you can add
arbitrary numbers to an item in the dateItems and let the convert
command handle the calculations that span minute, hour, day, month, and
year boundaries.

For example, suppose you start with 9:30 AM , convert that time to
dateItems format, then add 45 minutes to item 5 (the minute) of the
resulting value. This gives you 75 as the minute. When you convert the
value to any other time format, the convert command automatically
converts "75 minutes" to "1 hour and 15 minutes":
-----------






More information about the pmwiki-users mailing list