当前位置: 首页>>代码示例>>Python>>正文


Python utils.adjust_datetime_to_timezone函数代码示例

本文整理汇总了Python中timezones.utils.adjust_datetime_to_timezone函数的典型用法代码示例。如果您正苦于以下问题:Python adjust_datetime_to_timezone函数的具体用法?Python adjust_datetime_to_timezone怎么用?Python adjust_datetime_to_timezone使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了adjust_datetime_to_timezone函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: save_model

 def save_model(self, request, obj, form, change):
     utz = request.user.get_profile().timezone
     if obj.start:
         obj.start = adjust_datetime_to_timezone(obj.start, utz, TZ)
     if obj.end:
         obj.end = adjust_datetime_to_timezone(obj.end, utz, TZ)
     obj.save()
开发者ID:OpenProximity,项目名称:OpenProximity,代码行数:7,代码来源:admin.py

示例2: created_local

 def created_local(self):
     if hasattr(self.service.user, 'get_profile'):
         return adjust_datetime_to_timezone(
             self.created,
             'UTC',
             unicode(self.service.user.get_profile().timezone)
         )
     else:
         return adjust_datetime_to_timezone(self.created, 'UTC', TIME_ZONE)
开发者ID:rickeyski,项目名称:causal,代码行数:9,代码来源:models.py

示例3: created_local

 def created_local(self):
     """Calculate the created time using timexone to give a datetime
     in the users time zone."""
     if hasattr(self, 'created'):
         if hasattr(self.user, 'get_profile'):
             return adjust_datetime_to_timezone(self.created, 'UTC', unicode(self.user.get_profile().timezone))
         else:
             return adjust_datetime_to_timezone(self.created, 'UTC', TIME_ZONE)
     else:
         return None
开发者ID:1stvamp,项目名称:causal,代码行数:10,代码来源:models.py

示例4: get_ievent

def get_ievent(request, d, event_id):
    from django.conf import settings
    from timezones.utils import adjust_datetime_to_timezone
    from events.models import Event
    
    site_url = get_setting('site', 'global', 'siteurl')
    
    event = Event.objects.get(id=event_id)
    e_str = "BEGIN:VEVENT\n"
    
    # organizer
    organizers = event.organizer_set.all()
    if organizers:
        organizer_name_list = [organizer.name for organizer in organizers]
        e_str += "ORGANIZER:%s\n" % (', '.join(organizer_name_list))
    
    # date time 
    if event.start_dt:
        start_dt = adjust_datetime_to_timezone(event.start_dt, settings.TIME_ZONE, 'GMT')
        start_dt = start_dt.strftime('%Y%m%dT%H%M%SZ')
        e_str += "DTSTART:%s\n" % (start_dt)
    if event.end_dt:
        end_dt = adjust_datetime_to_timezone(event.end_dt, settings.TIME_ZONE, 'GMT')
        end_dt = end_dt.strftime('%Y%m%dT%H%M%SZ')
        e_str += "DTEND:%s\n" % (end_dt)
    
    # location
    if event.place:
        e_str += "LOCATION:%s\n" % (event.place.name)
        
    e_str += "TRANSP:OPAQUE\n"
    e_str += "SEQUENCE:0\n"
    
    # uid
    e_str += "UID:uid%[email protected]%s\n" % (event.pk, d['domain_name'])
    
    event_url = "%s%s" % (site_url, reverse('event', args=[event.pk]))
    d['event_url'] = event_url
    
    # text description
    e_str += "DESCRIPTION:%s\n" % (build_ical_text(event,d))
    #  html description
    e_str += "X-ALT-DESC;FMTTYPE=text/html:%s\n" % (build_ical_html(event,d))
    
    e_str += "SUMMARY:%s\n" % strip_tags(event.title)
    e_str += "PRIORITY:5\n"
    e_str += "CLASS:PUBLIC\n"
    e_str += "BEGIN:VALARM\n"
    e_str += "TRIGGER:-PT30M\n"
    e_str += "ACTION:DISPLAY\n"
    e_str += "DESCRIPTION:Reminder\n"
    e_str += "END:VALARM\n"
    e_str += "END:VEVENT\n"
        
    return e_str
开发者ID:BakethemPie,项目名称:tendenci,代码行数:55,代码来源:utils.py

示例5: forwards

 def forwards(self, orm):
     all_news = orm['news.News'].objects.all()
     now = datetime.datetime.now()
     now_with_tz = adjust_datetime_to_timezone(now, settings.TIME_ZONE) 
     for news in all_news:
         if news.timezone and news.release_dt and news.timezone.zone != settings.TIME_ZONE:
             time_diff = adjust_datetime_to_timezone(now, news.timezone) - now_with_tz
             news.release_dt_local = news.release_dt + time_diff
         else:
             news.release_dt_local = news.release_dt
         # only update the release_dt_local field
         orm['news.News'].objects.filter(id=news.id).update(release_dt_local=news.release_dt_local)
开发者ID:BillTheBest,项目名称:tendenci,代码行数:12,代码来源:0009_populate_release_dt_local.py

示例6: forwards

 def forwards(self, orm):
     articles = orm['articles.Article'].objects.all()
     now = datetime.datetime.now()
     now_with_tz = adjust_datetime_to_timezone(now, settings.TIME_ZONE) 
     for article in articles:
         if article.timezone and article.release_dt and article.timezone.zone != settings.TIME_ZONE:
             time_diff = adjust_datetime_to_timezone(now, article.timezone) - now_with_tz
             article.release_dt_local = article.release_dt + time_diff
         else:
             article.release_dt_local = article.release_dt
         # only update the release_dt_local field
         orm['articles.Article'].objects.filter(id=article.id).update(release_dt_local=article.release_dt_local)
开发者ID:BillTheBest,项目名称:tendenci,代码行数:12,代码来源:0008_populate_release_dt_local.py

示例7: coerce_datetime_tz

 def coerce_datetime_tz(self, datetime):
     server_tz = settings.TIME_ZONE
     if self.instance is None or self.instance.creator is None:
         user_tz = self.creator.get_profile().timezone
     else:
         user_tz = self.instance.creator.get_profile().timezone
     return tz_utils.adjust_datetime_to_timezone(datetime, user_tz, server_tz)
开发者ID:agentultra,项目名称:hnofficehours,代码行数:7,代码来源:forms.py

示例8: test_adjust_datetime_to_timezone

 def test_adjust_datetime_to_timezone(self):
     self.assertEqual(
         adjust_datetime_to_timezone(
             datetime(2008, 6, 25, 18, 0, 0), "UTC"
         ).strftime("%m/%d/%Y %H:%M:%S"),
         "06/25/2008 18:00:00"
     )
开发者ID:FernandoEscher,项目名称:django-timezones,代码行数:7,代码来源:tests.py

示例9: local_send_time

 def local_send_time(self):
     if self.billee.timezone:
         return adjust_datetime_to_timezone(
             self.send_date,
             settings.TIME_ZONE,
             self.billee.timezone
         )
     return self.send_date
开发者ID:hfeeki,项目名称:django-sms-gateway,代码行数:8,代码来源:message.py

示例10: clean_end

    def clean_end (self):
        date = self.cleaned_data["end"]
        if self.timezone:
            print "IN CLEAN END EDIT"
            print date
            date = adjust_datetime_to_timezone (date, self.timezone)
            print date

        return date
开发者ID:Ryochan7,项目名称:dcgamescheduler,代码行数:9,代码来源:forms.py

示例11: clean_start

    def clean_start (self):
        date = self.cleaned_data["start"]
        if self.timezone:
            print "IN CLEAN START EDIT"
            print date
            date = adjust_datetime_to_timezone (date, self.timezone)
            print date

        return date
开发者ID:Ryochan7,项目名称:dcgamescheduler,代码行数:9,代码来源:forms.py

示例12: stop_date_localized

 def stop_date_localized(self):
     """
     return localized stop date
     """
     from timezones.utils import adjust_datetime_to_timezone
     return adjust_datetime_to_timezone(
         self.stop_date,
         settings.TIME_ZONE, 
         self.user.get_profile().timezone)
开发者ID:debrice,项目名称:kaaloo,代码行数:9,代码来源:models.py

示例13: clean_completed_at

    def clean_completed_at(self):
        value = self.cleaned_data['completed_at']
        if value is None:
            return value

        time_zone = self.task.user.get_profile().time_zone
        localtime = value.replace(tzinfo=pytz.timezone(time_zone))
        utctime = adjust_datetime_to_timezone(localtime, time_zone, 'UTC')
        utctime_raw = utctime.replace(tzinfo=None)
        return utctime_raw
开发者ID:subakva,项目名称:velocette,代码行数:10,代码来源:forms.py

示例14: localize_date

def localize_date(value, to_tz=None):
    from timezones.utils import adjust_datetime_to_timezone
    try:
        if to_tz is None:
            to_tz = settings.UI_TIME_ZONE

        from_tz = settings.TIME_ZONE

        return adjust_datetime_to_timezone(value, from_tz=from_tz, to_tz=to_tz)
    except AttributeError:
        return ''
开发者ID:BIGGANI,项目名称:tendenci,代码行数:11,代码来源:base_filters.py

示例15: assign_release_dt_local

 def assign_release_dt_local(self):
     """
     convert release_dt to the corresponding local time
     
     example:
     
     if
         release_dt: 2014-05-09 03:30:00
         timezone: US/Pacific
         settings.TIME_ZONE: US/Central
     then
         the corresponding release_dt_local will be: 2014-05-09 05:30:00
     """
     now = datetime.now()
     now_with_tz = adjust_datetime_to_timezone(now, settings.TIME_ZONE)
     if self.timezone and self.release_dt and self.timezone.zone != settings.TIME_ZONE:
         time_diff = adjust_datetime_to_timezone(now, self.timezone) - now_with_tz
         self.release_dt_local = self.release_dt + time_diff
     else:
         self.release_dt_local = self.release_dt
开发者ID:MariusCC,项目名称:tendenci,代码行数:20,代码来源:models.py


注:本文中的timezones.utils.adjust_datetime_to_timezone函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。