Source code for khayyam.formatting.directives.time

# -*- coding: utf-8 -*-
from .persian import PersianNumberDirective
__author__ = 'vahid'


[docs]class PersianHour24Directive(PersianNumberDirective): """ Representing Hour24 format in persian form. """ def format(self, d): return super(PersianHour24Directive, self).format(d.hour) def post_parser(self, ctx, formatter): super(PersianHour24Directive, self).post_parser(ctx, formatter) if self.name in ctx and ctx[self.name]: ctx['hour'] = ctx[self.name]
[docs]class PersianHour12Directive(PersianNumberDirective): """ Representing Hour12 format in persian form. """ def format(self, d): return super(PersianHour12Directive, self).format(d.hour12()) def post_parser(self, ctx, formatter): super(PersianHour12Directive, self).post_parser(ctx, formatter) if self.name in ctx and ctx[self.name]: ctx['hour12'] = ctx[self.name]
[docs]class PersianMinuteDirective(PersianNumberDirective): """ Representing minute in persian form. """ def format(self, d): return super(PersianMinuteDirective, self).format(d.minute) def post_parser(self, ctx, formatter): super(PersianMinuteDirective, self).post_parser(ctx, formatter) if self.name in ctx and ctx[self.name]: ctx['minute'] = ctx[self.name]
[docs]class PersianSecondDirective(PersianNumberDirective): """ Representing second in persian form. """ def format(self, d): return super(PersianSecondDirective, self).format(d.second) def post_parser(self, ctx, formatter): super(PersianSecondDirective, self).post_parser(ctx, formatter) if self.name in ctx and ctx[self.name]: ctx['second'] = ctx[self.name]
[docs]class PersianMicrosecondDirective(PersianNumberDirective): """ Representing Microsecond in persian form. """ def format(self, d): return super(PersianMicrosecondDirective, self).format('%.6d' % d.microsecond) def post_parser(self, ctx, formatter): super(PersianMicrosecondDirective, self).post_parser(ctx, formatter) if self.name in ctx and ctx[self.name]: ctx['microsecond'] = ctx[self.name]