tzinfo

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

﹥>﹥吖頭↗ 提交于 2020-01-18 04:53:04
问题 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 .... Exiting c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/tzinfo-1.1.0/lib/tzinfo/data_source.rb:199: in `rescue in create_default_data_source': No timezone data source could be found. To resolve this, either install TZInfo::Data (e.g. by running

Printing correct time using timezones, Python

社会主义新天地 提交于 2019-12-22 04:07:51
问题 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 2.5.4 now = datetime.now() print now.strftime( "%a %b %d %X" ) # %X is "locale's appropriate time rep" pst = now.replace( tzinfo=Pacific ) print pst.strftime( "%a %b %d %X" ) We get: Mon Jan 18 17:30:16 Mon Jan 18 17:30:16 I found if I add %z, I can add

How to Convert TZInfo identifier to Rails TimeZone name/key

早过忘川 提交于 2019-12-18 11:09:56
问题 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 example: "Pacific/Honolulu" => converted to => "Hawaii" Both are available in ActiveSupport::TimeZone < Object mapping but rails uses the key [i.g. "Eastern Time (US & Canada)" ] in drop-downs, validation & storing to Time.use_zone() . Based on what I understand

Extract historic leap seconds from tzdata

六眼飞鱼酱① 提交于 2019-12-18 03:12:06
问题 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 case is to convert between gps-time (which is basically the number of seconds since the first GPS-satellite was switched on in 1980) and UTC or local time. UTC is adjusted for leap-seconds every now and then, while gps-time increases linearly. This

Extract historic leap seconds from tzdata

拈花ヽ惹草 提交于 2019-12-18 03:11:19
问题 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 case is to convert between gps-time (which is basically the number of seconds since the first GPS-satellite was switched on in 1980) and UTC or local time. UTC is adjusted for leap-seconds every now and then, while gps-time increases linearly. This

Can I export pandas DataFrame to Excel stripping tzinfo?

假如想象 提交于 2019-12-12 03:57:34
问题 I have a timezone aware TimeSeries in pandas 0.10.1. I want to export to Excel, but the timezone prevents the date from being recognized as a date in Excel. In [40]: resultado Out[40]: fecha_hora 2013-04-11 13:00:00+02:00 31475.568 2013-04-11 14:00:00+02:00 37263.072 2013-04-11 15:00:00+02:00 35979.434 2013-04-11 16:00:00+02:00 35132.890 2013-04-11 17:00:00+02:00 36356.584 If I strip the tzinfo with .tz_convert(None) , the date gets converted to UTC: In [41]: resultado.tz_convert(None) Out[41

Ruby 'gem tzinfo'

不羁岁月 提交于 2019-12-12 02:29:33
问题 From my previous question about timezones, I decided to use the Ruby gem tzinfo to get access to time zone data. This means storing scheduled times as a timezone name (e.g. "America/Toronto"), and then using the Ruby tzinfo gem and tzinfo database to look up the correct UTC time from a desired local time. My understanding is that the database of time zones changes from time to time because different jurisdictions call for different policies on the (non)application of Daylight Savings Time.

Can't execute bundle exec rake db:migrate due to tzinfo error

眉间皱痕 提交于 2019-12-12 02:26:55
问题 As stated in the title. I got C:\...>bundle exec rake db:migrate rake aborted! LoadError: cannot load such file -- tzinfo C:/.../config/application.rb:3:in `require' C:/.../config/application.rb:3:in `<top (required )>' C:/.../Rakefile:4:in `require' C:/.../Rakefile:4:in `<top (required)>' (See full trace by running task with --trace) My rails are v4.2.2 and my ruby is v2.2 on Windows 8 (64bit). According to various SO questions I went through I might get this error due to some

How to use datetime.tzinfo in Python?

一笑奈何 提交于 2019-12-11 05:14:03
问题 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 timezone with daylight saving time applied automatically? How do I set to subtract one hour automatically only during dst? 回答1: Python doesn't really implement well timezones. According to the documentation, tzinfo is just an abstract class meant to be

Insert a tzinfo into datetime

浪尽此生 提交于 2019-12-10 01:52:18
问题 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 date string and would like to transform it into a timezone-aware datetime object. I prefer to use the following method: def transform_date(date_string, tzinfo): fmt = '%Y-%m-%d' # Where do I insert tzinfo? date = datetime.strptime(date_string, fmt) return date Is