How to use the pytz.common_timezones function in pytz

To help you get started, we’ve selected a few pytz examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dirn / When.py / tests / test_when.py View on Github external
def test_common_timezones(self):
        """Test when.common_timezones()"""
        # Make sure common_timezones() matches pytz's version
        common_timezones = when.common_timezones()
        self.assertEqual(common_timezones, pytz.common_timezones)
github linuxmint / cinnamon / files / usr / share / cinnamon / cinnamon-settings / modules / cs_calendar.py View on Github external
self.city_combo.connect('changed', self.on_city_changed)

        self.region_list = Gtk.ListStore(str, str)
        self.region_combo.set_model(self.region_list)
        renderer_text = Gtk.CellRendererText()
        self.region_combo.pack_start(renderer_text, True)
        self.region_combo.add_attribute(renderer_text, "text", 1)
        self.region_combo.set_id_column(0)

        renderer_text = Gtk.CellRendererText()
        self.city_combo.pack_start(renderer_text, True)
        self.city_combo.add_attribute(renderer_text, "text", 1)
        self.city_combo.set_id_column(0)

        self.region_map = {}
        for tz in pytz.common_timezones:
            try:
                region, city = tz.split('/', maxsplit=1)
            except:
                continue

            if region not in self.region_map:
                self.region_map[region] = Gtk.ListStore(str, str)
                self.region_list.append([region, _(region)])
            self.region_map[region].append([city, _(city)])
github p2pu / learning-circles / community_calendar / forms.py View on Github external
# coding=utf-8
from django import forms
from django.utils.translation import ugettext as _
from django.utils import timezone

from .models import Event

import pytz
import datetime
import logging

logger = logging.getLogger(__name__)

class EventForm(forms.ModelForm):
    TIMEZONES = [('', _('Select one of the following')),] + list(zip(pytz.common_timezones, pytz.common_timezones))

    timezone = forms.ChoiceField(choices=TIMEZONES, label=_('What timezone is the above time in?'))
    date = forms.DateField()
    time = forms.TimeField(input_formats=['%I:%M %p']) #TODO get this value as 24hr hh:mm:ss or hh:mm and localize in the UX

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        if self.instance.pk:
            self.fields['date'].initial = self.instance.local_datetime().date()
            self.fields['time'].initial = self.instance.local_datetime().time()

    def save(self, commit=True):
        event_datetime = datetime.datetime.combine(
            self.cleaned_data['date'],
            self.cleaned_data['time']
        )
github cloudlinux / kuberdock-platform / kubedock / api / settings.py View on Github external
def get_timezone():
    search_result_length = 5
    search = request.args.get('s', '')
    search = search.lower()
    count = 0
    timezones_list = []
    for tz in common_timezones:
        if search in tz.lower():
            timezones_list.append(append_offset_to_timezone(tz))
            count += 1
            if count >= search_result_length:
                break

    return jsonify({'status': 'OK', 'data': timezones_list})
github liqd / a4-opin / euth / users / models.py View on Github external
('O', _('Other')),
        ],
    )

    languages = models.CharField(
        blank=True,
        verbose_name=_('Languages'),
        max_length=150,
        help_text=_('Enter the languages you’re speaking.')
    )

    timezone = models.CharField(
        blank=True,
        verbose_name=_('Time zone'),
        max_length=100,
        choices=[(t, t) for t in common_timezones]
        )

    objects = auth_models.UserManager()

    USERNAME_FIELD = 'email'
    REQUIRED_FIELDS = ['username']

    class Meta:
        verbose_name = _("User")
        verbose_name_plural = _("Users")

    def get_absolute_url(self):
        from django.core.urlresolvers import reverse
        return reverse('profile', kwargs={'slug': str(self.username)})

    def __str__(self):
github NMGRL / pychron / pychron / igsn / igsn_service.py View on Github external
_collection_start_date = Date
    _collection_start_time = Time

    collection_date_precision = Enum('year', 'month', 'day', 'time')
    original_archive = Str

    # classification
    rock_type = Enum(ROCK_TYPES)  # 'Igneous'
    sub_rock_type = Str  # 'Plutonic'
    rock_type_detail = Str

    sub_rock_types = Property(depends_on='rock_type')
    rock_type_details = Property(depends_on='rock_type')

    timezone = Enum(pytz.common_timezones)

    xml_content = Str

    def __init__(self, *args, **kw):
        super(IGSNSampleModel, self).__init__(*args, **kw)

        dt = datetime.now()
        self._collection_start_date = dt.date()
        self._collection_start_time = dt.time()
        self.timezone = 'US/Mountain'

    def assemble_content(self):
        xmlns = 'http://app.geosamples.org'
        xsi = 'http://www.w3.org/2001/XMLSchema-instance'
        nsmap = {None: xmlns,
                 'xsi': xsi}
github hforge / ikaaro / users_views.py View on Github external
root = context.root

        # Languages
        user_language = resource.get_value('user_language')
        languages = [
            {'code': code,
             'name': get_language_name(code),
             'is_selected': code == user_language}
            for code in root.get_available_languages() ]

        # Timezone
        user_timezone = resource.get_value('user_timezone')
        timezones = [
            {'name': name,
             'is_selected': name == user_timezone}
            for name in common_timezones ]

        return {'languages': languages,
                'timezones': timezones}
github FrancoisSchnell / GPicSync / src / gpicsync-GUI.py View on Github external
codeset = locale.getdefaultlocale()[1]



#if 1: # checking wx version installed (for unicde dev)
#    import wxversion
#    print ("wxversion", wxversion.getInstalled())
#    print ("Python verion is",(sys.version))

try:
    import pytz
except ImportError:
    print ("couldn't import pytz")
    timezones = []
else:
    timezones = pytz.common_timezones
if 0: # tests
    import pytz
    timezones = pytz.common_timezones
    print (timezones)
    fzones=open("zones.txt","w")
    fzones.write(str(timezones))
    fzones.close()
    
class GUI(wx.Frame):
    """Main Frame of GPicSync"""
    def __init__(self,parent, title):
        """Initialize the main frame"""
        global bkg

        wx.Frame.__init__(self, parent, wx.ID_ANY, title="GPicSync",size=(1000,600))
        favicon = wx.Icon('gpicsync.ico', wx.BITMAP_TYPE_ICO, 16, 16)
github ulule / django-metasettings / metasettings / choices.py View on Github external
("UY", "USD"),
    ("UZ", "USD"),
    ("VU", "USD"),
    ("VE", "USD"),
    ("VN", "USD"),
    ("VG", "USD"),
    ("VI", "USD"),
    ("WF", "USD"),
    ("EH", "USD"),
    ("YE", "USD"),
    ("ZM", "USD"),
    ("ZW", "USD"),
)

TIMEZONE_CHOICES = sorted(
    ((tz, tz) for tz in pytz.common_timezones), key=lambda x: x[1]
)

TIME_ZONE = "Europe/Paris"
github michaeljohnbarr / django-timezone-utils / timezone_utils / choices.py View on Github external
tz_offset.offset_string,
                    tuple(choices_dict[tz_offset])
                )
            )

    # Cast the timezone choices to a tuple and return
    return tuple(choices)


# ==============================================================================
# CHOICES CONSTANTS
# ==============================================================================
# Standard (unaltered) pytz timezone choices
ALL_TIMEZONES_CHOICES = tuple(zip(pytz.all_timezones, pytz.all_timezones))
COMMON_TIMEZONES_CHOICES = tuple(
    zip(pytz.common_timezones, pytz.common_timezones)
)

# Grouped by timezone offset, with "GMT-05:00" as the group name
GROUPED_ALL_TIMEZONES_CHOICES = get_choices(
    timezones=pytz.all_timezones,
    grouped=True
)
GROUPED_COMMON_TIMEZONES_CHOICES = get_choices(
    timezones=pytz.common_timezones,
    grouped=True
)

# Sorted by timezone offset, with "(GMT-05:00) US/Eastern" as the display name
PRETTY_ALL_TIMEZONES_CHOICES = get_choices(timezones=pytz.all_timezones)
PRETTY_COMMON_TIMEZONES_CHOICES = get_choices(timezones=pytz.common_timezones)