[RFM] Timestamps & localization

24 views
Skip to first unread message

wbr

unread,
Apr 21, 2010, 12:08:14 AM4/21/10
to RFM Community
I'm wondering if there is a way to localize timestamp data in RFM. I'm
pulling timestamps from Filemaker using RFM, and they're wrong once
they're ruby'ized. The RFM timestamps appear to ignore the local
timezone of my Rails server. I could brute-force each timestamp I work
with, but I'm guessing there is a better way. Maybe a setting in the
Server object that says all timestamps are +0800 or -0700? Or is there
a general Ruby or Rails setting I'm missing?

Thanks,
Bill

--
You received this message because you are subscribed to the Google Groups "RFM Community" group.
To post to this group, send email to rfmcom...@googlegroups.com.
To unsubscribe from this group, send email to rfmcommunity...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rfmcommunity?hl=en.

lardawge

unread,
Apr 21, 2010, 8:04:28 AM4/21/10
to RFM Community
I am trying to wrap my head around what your needing to do... could
you post a more concrete example? My initial thought would be since
Filemaker doesn't send time zone info, it would be something you would
need to do yourself within rails...

Larry

wbr

unread,
Apr 21, 2010, 4:21:53 PM4/21/10
to rfmcom...@googlegroups.com
Yep, that's the problem - Filemaker doesn't send time-zone info, so the DateTime objects assume UTC (+0000).

I'm comparing Filemaker timestamps with various other DateTime objects in ruby, and the DateTime objects from Filemaker are 8 hours off. Currently, I'm adding 8 hours to all DateTime objects from Filemaker, but I'd rather handle this centrally. I'm thinking if I patch the point where RFM converts the timestamp from xml to a DateTime object, I could just set this server-wide to always assume my local time zone when creating DateTime objects from FM timestamps.

lardawge

unread,
Apr 22, 2010, 12:03:51 AM4/22/10
to RFM Community
One possible way to handle this would be to have a config for timezone
offset which would calculate the difference from the filemaker server
to the rails server... Post it as a ticket on github for reference
along with whatever steps you used or patch and I will have a look at
it.

I am making some big changes in the way rfm's API works and will post
here soon as to what those are. The current api is a fish out of water
when trying to intergrate it into a rails app and I am looking to fix
that. I think I will keep a branch of 1.4.0 for a while for bug fixes
and other things but hopfully get people switched over to the new 2.0.

Larry
> For more options, visit this group athttp://groups.google.com/group/rfmcommunity?hl=en.- Hide quoted text -
>
> - Show quoted text -

Atsushi Matsuo

unread,
Apr 22, 2010, 11:32:42 AM4/22/10
to rfmcom...@googlegroups.com
What's the value of config.time_zone in Rails config/environment.rb?

--
Atsushi Matsuo
http://www.famlog.jp/


On Apr 21, wbr <banane...@gmail.com> wrote:
> Yep, that's the problem - Filemaker doesn't send time-zone info, so the DateTime objects assume UTC (+0000).
>
> I'm comparing Filemaker timestamps with various other DateTime objects in ruby, and the DateTime objects from Filemaker are 8 hours off. Currently, I'm adding 8 hours to all DateTime objects from Filemaker, but I'd rather handle this centrally. I'm thinking if I patch the point where RFM converts the timestamp from xml to a DateTime object, I could just set this server-wide to always assume my local time zone when creating DateTime objects from FM timestamps.

wbr

unread,
Apr 22, 2010, 6:12:23 PM4/22/10
to rfmcom...@googlegroups.com
config.time_zone = 'Pacific Time (US & Canada)'

... which appears to have no effect on the parsed timestamp from Filemaker.

I haven't tried the following yet, but looks like we can modify the following RFM function to include a time_zone in the parsing:

module RFM::Result
class ResultSet...
def initialize...
case
...
when "timestamp"
### server_time_zone can be whatever you want - a Server config, a Rails config, a Ruby constant, Time.now.zone, etc... ###
return DateTime.strptime("#{value} #{server_time_zone}", "#{@result_set.timestamp_format} %Z")
...
end
end
end
end


This should work but I suspect there is a better way to do this. Somehow it must be possible to tell ruby that all parsed times not containing zone info should assume local time zone.

Bill

Atsushi Matsuo

unread,
Apr 23, 2010, 1:56:49 PM4/23/10
to rfmcom...@googlegroups.com
OK, I tried the following. How about it?

when "timestamp"
if Time.zone
time_zone = Time.zone.now.zone # for Rails
else
time_zone = Time.now.zone
end
return DateTime.strptime("#{value} #{time_zone}", "#{@result_set.timestamp_format} %z")

--
Atsushi Matsuo
http://www.famlog.jp/


On 2010/04/23, at 7:12, wbr wrote:
> config.time_zone = 'Pacific Time (US & Canada)'
>
> ... which appears to have no effect on the parsed timestamp from Filemaker.
>
> I haven't tried the following yet, but looks like we can modify the following RFM function to include a time_zone in the parsing:
>
> module RFM::Result
> class ResultSet...
> def initialize...
> case
> ...
> when "timestamp"
> ### server_time_zone can be whatever you want - a Server config, a Rails config, a Ruby constant, Time.now.zone, etc... ###
> return DateTime.strptime("#{value} #{server_time_zone}", "#{@result_set.timestamp_format} %Z")
> ...
> end
> end
> end
> end
>
>
> This should work but I suspect there is a better way to do this. Somehow it must be possible to tell ruby that all parsed times not containing zone info should assume local time zone.

wbr

unread,
Apr 23, 2010, 6:12:35 PM4/23/10
to rfmcom...@googlegroups.com
Yep, that's pretty much it, although I don't know what Time.zone is supposed to do in Rails.

Alternatively, we could use a DateTime mod. I couldn't find any way to give DateTime a default zone to use with strptime, so this mod adds it. This would negate the need to modify anything in RFM. But it would potentially change DateTime behavior for your entire application. Again... not sure if this is the best way to handle this, but it works for my needs.

http://pastie.org/932294

Bill
Reply all
Reply to author
Forward
0 new messages