Questions tagged [tzinfo]

tzinfo is a Ruby timezone library to provide daylight savings aware transformations between times in different timezones.

TZInfo requires a source of timezone data. There are two built-in options:

  1. The separate TZInfo::Data library (the tzinfo-data gem). TZInfo::Data contains a set of Ruby modules that are generated from the IANA Time Zone Database.
  2. A zoneinfo directory. Most Unix-like systems include a zoneinfo directory containing timezone definitions. These are also generated from the IANA Time Zone Database.

By default, TZInfo::Data will be used. If TZInfo::Data is not available (i.e. if require 'tzinfo/data' fails), then TZInfo will search for a zoneinfo directory instead.

Custom data sources can also be created and used with TZInfo.

Read more

66 questions
79
votes
14 answers

TZInfo::DataSourceNotFound error starting Rails v4.1.0 server on Windows

I have created a new application using Ruby on Rails v4.1.0. When attempting to start a server or console on Windows, I am encountering the following error: $ rails server Booting WEBrick Rails 4.1.0 application starting in development on…
John
  • 1,677
  • 4
  • 15
  • 26
39
votes
3 answers

attribute 'tzinfo' of 'datetime.datetime' objects is not writable

How do I set the timezone of a datetime instance that just came out of the datastore? When it first comes out it is in UTC. I want to change it to EST. I'm trying, for example: class Book( db.Model ): creationTime = db.DateTimeProperty() When…
bobobobo
  • 64,917
  • 62
  • 258
  • 363
30
votes
3 answers

How to Convert TZInfo identifier to Rails TimeZone name/key

How do you convert js values received as TZInfo identifiers to Rails TimeZone name/key? FROM: "America/New_York" returned from JavaScript TZinfo detection TO: "Eastern Time (US & Canada)" convention used in Rails TimeZone or another…
21
votes
3 answers

Python timezone '%z' directive for datetime.strptime() not available

Using '%z' pattern of datetime.strptime() I have a string text that represent a date and I'm perfectly able to parse it and transform it into a clean datetime object: date = "[24/Aug/2014:17:57:26" dt = datetime.strptime(date, "[%d/%b/%Y:%H:%M:%S") …
c24b
  • 5,278
  • 6
  • 27
  • 35
20
votes
2 answers

Extract historic leap seconds from tzdata

Is there a way to extract the moment of historic leap seconds from the time-zone database that is distributed on most linux distributions? I am looking for a solution in python, but anything that works on the command line would be fine too. My use…
Bas Swinckels
  • 18,095
  • 3
  • 45
  • 62
14
votes
1 answer

Insert a tzinfo into datetime

I have the following tzinfo concrete subclass definition: from datetime import datetime, timedelta, tzinfo class ManilaTime(tzinfo): def utcoffset(self, dt): return timedelta(hours=8) def tzname(self, dt): return "Manila" I obtain a…
Kit
  • 30,365
  • 39
  • 105
  • 149
13
votes
1 answer

Why doesn't pytz localize() produce a datetime object with tzinfo matching the tz object that localized it?

Is there anyone who can help me understand what's going on here? import pytz from datetime import datetime tz = pytz.timezone('Europe/Berlin') print repr(tz) # dt = datetime(2011, 1, 3, 18, 40) result =…
bjmc
  • 2,970
  • 2
  • 32
  • 46
10
votes
3 answers

ruby on rails server not starting

Hi, when I try to run rails server, it just exits and displays the message below: C:\rails_project\first_app>rails s => Booting WEBrick => Rails 4.1.0 application starting in development on http0 0 0 0:3000 => Run `rails server -h` for more startup…
agent_bean
  • 1,493
  • 1
  • 16
  • 30
9
votes
3 answers

Printing correct time using timezones, Python

Extends Ok, we are not having a good day today. When you attach the correct tzinfo object to a datetime instance, and then you strftime() it, it STILL comes out in UTC, seemingly ignoring the beautiful tzinfo object I attached to it. # python…
bobobobo
  • 64,917
  • 62
  • 258
  • 363
6
votes
2 answers

How to use datetime.tzinfo in Python?

I have no idea how to use datetime.tzinfo module. I have to convert a datetime data from UTC to local timezone and if I retrieve '+2'(which means gmt+2) how do I convert this to tzinfo object? Also, is it possible to convert from UTC to local…
Charlie Lee
  • 91
  • 1
  • 5
6
votes
3 answers

How do I get Rails TimeZone names from obsolete TZInfo identifiers?

There is already a question which answers how to convert "America/Los_Angeles" to "Pacific Time (US & Canada)". However I want to convert "US/Pacific" and other obsolete time zones to Rails TimeZone. I am unable to find anything in the library which…
user842563
  • 125
  • 1
  • 6
5
votes
1 answer

Django AttributeError: 'str' object has no attribute 'tzinfo'

I am getting this error at the following code, when I try to get all the objects from my database: data1 = Data.objects.all() for dataset in data1: Here is my model: class Data(models.Model): id = models.AutoField(db_column='ID', primary_key=True) …
Noootron27
  • 65
  • 1
  • 1
  • 6
5
votes
1 answer

tzinfo-data + Rails is reporting the wrong timezone offset for ireland

I am seeing some strange results whilst trying to retrieve the time zone for Ireland. On Mac OS X (without tzinfo-data) include ActionView::Helpers::FormOptionsHelper time_zone_options_for_select.split.select { |opt| opt =~ /Dublin/ } =>…
Sam Stickland
  • 637
  • 1
  • 6
  • 17
4
votes
2 answers

RoR Rake - database error about a gem

I am trying to create a db in my ror application with this command: rake db:create and I got this error: Could not find tzinfo-0.3.26 in any of the sources But when I did the "gem list" command, it turned out I had a newer version of this gem:…
Genadinik
  • 18,153
  • 63
  • 185
  • 284
4
votes
1 answer

Difference of two timedelta objects, with timezones

I would like to calculate how many hours there are in a date interval: for example "2014.03.29-30" should give 47, because of the daylight savings. My method is making two datetime objects, in the example the following: datetime.datetime(2014, 3,…
Rolf
  • 331
  • 4
  • 13
1
2 3 4 5