Differences between revisions 3 and 4
Revision 3 as of 2006-09-25 09:31:34
Size: 797
Editor: 211
Comment:
Revision 4 as of 2007-12-26 08:38:22
Size: 802
Editor: 203
Comment:
Deletions are marked like this. Additions are marked like this.
Line 17: Line 17:
#! encoding:utf-8 # -*- coding:utf-8 -*-

특정일까지 몇일 남았나(지났나)를 알려주는 매크로

사용법

DueDate(YYYY-MM-DD)

예제

이제 2006년도 [[DueDate(2007-01-01)]] 

이제 2006년도 DueDate(2007-01-01)

코드

   1 # -*- coding:utf-8 -*-
   2 import datetime
   3 
   4 def execute(macro, args):
   5     args = args.split(',',0)[0]
   6     try:
   7         year,month,day = [int(each) for each in args.split('-')]
   8     except ValueError:
   9         return macro.formatter.rawHTML(
  10             '<font color="red">Invalid format, it has to be like 2006-09-25</font>')
  11     delta = datetime.date(year,month,day) - datetime.date.today()
  12     return macro.formatter.rawHTML(
  13         u'%s 까지 %i 일 남았습니다.' % (args, delta.days))


CategoryMacro

DueDateMacro (last edited 2011-08-03 11:01:10 by localhost)

web biohackers.net