Tags:
create new tag
view all tags

Question

I am writing a small plugin and I need to tell the time lapsed since a certain date, which is passed to the plugin in the format: 13 Oct 2005.

Are there are TWiki core functions to:

  • parse the date (the format is flexible),
  • compute the number of days till "today"?

Or any other suggestions for me to proceed?

Thanks.

Environment

TWiki version: TWikiRelease04Sep2004
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin
Server OS:  
Web server:  
Perl version:  
Client OS:  
Web Browser:  
Categories: Plugins

-- PankajPant - 24 Jan 2006

Answer

ALERT! If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.

In addition to the various PERL functions available from CPAN and used in a variety of plugins that handle date parsting, there is also a TimeSincePlugin. I'm using it in Dakar, I'm not sure how it fucntions in Cairo.

-- AntonAylward - 25 Jan 2006

Thanks for the tip. Date::Calc seems to have all that I need and much more.

-- PankajPant - 25 Jan 2006

You don't need to write a plugin or make use of Perl at all. The SpreadSheetPlugin has

  • FORMATTIME( serial, text ) -- convert a serialized date into a date string
  • FORMATGMTIME( serial, text ) -- convert a serialized date into a GMT date string
  • TIME( text ) -- convert a date string into a serialized date number
  • TIMEADD( serial, value, unit ) -- add a value to a serialized date
  • TIMEDIFF( serial_1, serial_2, unit ) -- time difference between two serialized dates
  • TODAY( ) -- serialized date of today at midnight GMT

Why make work for yourself?

-- AntonAylward - 25 Jan 2006

Edit | Attach | Watch | Print version | History: r5 < r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r5 - 2006-01-25 - PeterThoeny
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.