Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(16)  |  Call(12)  |  Derive(0)  |  Import(4)

        def format_time(db=None, config=None, zone=None, nick=None, channel=None,
                 time=None):
    """Return a formatted string of the given time in the given zone.

    `time`, if given, should be a naive `datetime.datetime` object and will be
    treated as being in the UTC timezone. If it is not given, the current time
    will be used. If `zone` is given and `pytz` is available, `zone` must be
    present in the IANA Time Zone Database; `get_timezone` can be helpful for
    this. If `zone` is not given or `pytz` is not available, UTC will be
    assumed.

    The format for the string is chosen in the following order:

    1. The format for `nick` in `db`, if one is set and valid.
    2. The format for `channel` in `db`, if one is set and valid.
    3. The default format in `config`, if one is set and valid.
    4. ISO-8601

    If `db` is not given or is not set up, steps 1 and 2 are skipped. If config
    is not given, step 3 will be skipped."""
    tformat = None
    if db:
        if nick and nick in db.preferences:
            tformat = db.preferences.get(nick, 'time_format')
        if not tformat and channel in db.preferences:
            tformat = db.preferences.get(channel, 'time_format')
    if not tformat and config and config.has_option('core',
                                                    'default_time_format'):
        tformat = config.core.default_time_format
    if not tformat:
        tformat = '%F - %T%Z'

    if not time:
        time = datetime.datetime.utcnow()

    if not pytz or not zone:
        return time.strftime(tformat)
    else:
        if not time.tzinfo:
            utc = pytz.timezone('UTC')
            time = utc.localize(time)
        zone = pytz.timezone(zone)
        return time.astimezone(zone).strftime(tformat)
        


src/w/i/willie-4.3.0/willie/modules/seen.py   willie(Download)
import time
import datetime
from willie.tools import Ddict, Nick, get_timezone, format_time
from willie.module import commands, rule, priority
 
                          trigger.sender)
        saw = datetime.datetime.utcfromtimestamp(timestamp)
        timestamp = format_time(bot.db, bot.config, tz, trigger.nick,
                                trigger.sender, saw)
 

src/w/i/willie-HEAD/willie/modules/seen.py   willie(Download)
import time
import datetime
from willie.tools import Ddict, Nick, get_timezone, format_time
from willie.module import commands, rule, priority
 
                          trigger.sender)
        saw = datetime.datetime.utcfromtimestamp(timestamp)
        timestamp = format_time(bot.db, bot.config, tz, trigger.nick,
                                trigger.sender, saw)
 

src/w/i/willie-4.3.0/willie/modules/clock.py   willie(Download)
import datetime
from willie.module import commands, example, OP
from willie.tools import get_timezone, format_time
 
 
        zone = get_timezone(bot.db, bot.config, None, trigger.nick,
                            trigger.sender)
    time = format_time(bot.db, bot.config, zone, trigger.nick, trigger.sender)
    bot.say(time)
 
                                       trigger.sender)
        try:
            timef = format_time(zone=tz)
        except:
            bot.reply("That format doesn't work. Try using"
                                       trigger.sender)
        try:
            timef = format_time(zone=tz)
        except:
            bot.reply("That format doesn't work. Try using"

src/w/i/willie-HEAD/willie/modules/clock.py   willie(Download)
import datetime
from willie.module import commands, example, OP
from willie.tools import get_timezone, format_time
 
 
        zone = get_timezone(bot.db, bot.config, None, trigger.nick,
                            trigger.sender)
    time = format_time(bot.db, bot.config, zone, trigger.nick, trigger.sender)
    bot.say(time)
 
                                       trigger.sender)
        try:
            timef = format_time(zone=tz)
        except:
            bot.reply("That format doesn't work. Try using"
                                       trigger.sender)
        try:
            timef = format_time(zone=tz)
        except:
            bot.reply("That format doesn't work. Try using"

src/w/i/willie-4.3.0/willie/modules/remind.py   willie(Download)
    if duration >= 60:
        remind_at = datetime.utcfromtimestamp(t)
        timef = willie.tools.format_time(bot.db, bot.config, tz, trigger.nick,
                                         trigger.sender, remind_at)
 

src/w/i/willie-HEAD/willie/modules/remind.py   willie(Download)
    if duration >= 60:
        remind_at = datetime.utcfromtimestamp(t)
        timef = willie.tools.format_time(bot.db, bot.config, tz, trigger.nick,
                                         trigger.sender, remind_at)
 

src/w/i/willie-4.3.0/willie/modules/tell.py   willie(Download)
    if not tellee in (Nick(teller), bot.nick, 'me'):
        tz = willie.tools.get_timezone(bot.db, bot.config, None, tellee)
        timenow = willie.tools.format_time(bot.db, bot.config, tz, tellee)
        bot.memory['tell_lock'].acquire()
        try:

src/w/i/willie-HEAD/willie/modules/tell.py   willie(Download)
    if not tellee in (Nick(teller), bot.nick, 'me'):
        tz = willie.tools.get_timezone(bot.db, bot.config, None, tellee)
        timenow = willie.tools.format_time(bot.db, bot.config, tz, tellee)
        bot.memory['tell_lock'].acquire()
        try: