Jump to: navigation, search

Date Handler

4 bytes added, 01:57, 12 July 2007
How to write a date handler
==How to write a date handler==
The framework for date handler plugins is in place. Here are the rules the language-specific plugins must obey to be compatible with the framework:
# * The plugin must define '''two''' classes: one for parsing and one for displaying dates.# * The parser class must derive from the [ DateParser] class:
from _DateParser import DateParser
class MyDateParser(DateParser):
:The parser class must provide <code>parse()</code> method. In fact, since the base class already defines such method, it is most likely that you will only need to re-define class constants and, maybe, the <code>init_string()</code> method.
# * The displayer class must derive from the [ DateDisplay] class:
from _DateDisplay import DateDisplay
class MyDateParser(DateDisplay):
:The displaer class mus provide <code>display()</code> method. Again, the base class already provides such method, but you may need to redefine it for your language, it is not that hard.
# * The plugin must register itself as the date handler. This is done by inserting the following code at the end of your <code></code> file:
from _DateHandler import register_datehandler

Navigation menu