Welcome Guest,Register Now
Log In

ANT Forum

Welcome guest, please Login or Register

   

Timestamp during fit to csv conversion problem

Rank

Total Posts: 8

Joined 2013-05-01

PM

Hi,

I'm using fit sdk for converting fit file to csv. Fit sdk is located on the server and problem is that date time in resulting csv file is always in server local format.

For example I have ride that happens at Fri Jul 19 07:41:34. When it is converted with fit sdk it has value Fri Jul 19 14:41:34 CEST 2013. How to keep original datetime format and zone. Is it possible to get also time zone info in csv, because then conversion would be easy to do.

Any suggestions?

Thanks      
RankRankRank

Total Posts: 91

Joined 2012-10-12

PM

Hi Minja,

FIT timestamps are always stored in UTC in the .FIT file. The FIT SDK datetime class should manage converting the 32bit timestamp to your environments time object ("java.util.date" or "system.Datetime" for .NET). Then generally you can convert conveniently using standard library calls.

What environment are you developing in?      
Rank

Total Posts: 8

Joined 2013-05-01

PM

Hi Shane,

I'm developing application in .NET C#. To better explain problem...Imagine you made ride in Swiss at 07:00 am. My server (also fit sdk) is located in Australia. When fit file is converted to csv files, I can see that time in csv is shown as 02:00 pm.

What I want is that when anybody opens that ride it should see 07:00am as the ride time.

How to know that at the moment of conversion, and how to know what is offset from UTC?

Thanks      
RankRankRank

Total Posts: 91

Joined 2012-10-12

PM

I am guessing you are working with Activity files. There is no requirement that the device record the user’s local time zone but there are a number of ways this can be encoded:
• If activity.local_timestamp is populated you can subtract from the activity.timestamp in the same message to establish the users offset from UTC.
• If monitoring_info message is present you can subtract monitoring_info.timestamp and monitoring_info.local_timestamp as above.
• If a settings file is available you can check device_settings.active_time_zone (need to look up what the offset is for each timezone defined in FIT time_zones enum) or device_settings.time_zone_offset (offset in multiples of 15min). These fields could be used to work out the users local time.

The recommended practice is to log at least one message that contains both a timestamp and a local_timestamp. If your file does not contain any of the above you may have to request an update from your manufacturer. As a workaround in this situation perhaps you could note the users timezone (offset from UTC) from their system when they upload the file. You could apply this offset later to display in the file creator’s local time.

Not sure why your decode is converting your timestamps to your local time. I played around with Dynastream.FIT.DateTime.GetDateTime() and it seemed to be doing what I would expect. Try setting ‘kind’ to ‘DateTimeKind.Utc’ and using ToUniversalTime() to make sure .NET is expressing your DateTime in UTC. If you are still having trouble post or PM me your decoding function.

Regards
ShaneP      
Rank

Total Posts: 8

Joined 2013-05-01

PM

Hi Shane,

First, I found in my code usage of ToLocalTime() method after using method ToUniversalTime(), which explain why I get all records in server local time.

But as you said, it still does not explain how to get offset. When I read .fit activity file with fit sdk as output I receive four csv files:

1. csv file with same name as fit file
2. csv file with sufix _laps
3. csv file with sufix _sessions
4. csv file with sufix _records

Enclosed you can find example of these files(except _sessions one).

I'm still not able to find record with time offset in these files. I do not know how much you know about fit sdk and is there any possibility that inside it config file(config.csv) I said give me time zone offset.

Thanks,

Minja






     

File Attachments

RankRankRank

Total Posts: 91

Joined 2012-10-12

PM

It looks like you are using quite an old version of the SDK (Pre Version 5.20). You can update at http://www.thisisant.com/developer/resources/downloads/.

The CSVTool won't modify data found in your original .FIT file. The other extensions (_laps, _sessions, etc.) are just filtered subsets of the main file (maybe with some extra formatting). They were intended as a convenience when developing Activity files. It is possible to filter unwanted messages using the tool but that is not your issue. The data you are interested in is just not in the original FIT file. It is possible this setting is recorded in another file (like Settings) but it may not be exposed.
     
Rank

Total Posts: 8

Joined 2013-05-01

PM

Hi Shane,

using last version of FITSDK I got _data.csv file which contains all information. There is column activity.timestamp(s) and several other column containing timestamp in seconds. How to convert those values to real time? If I use http://www.onlineconversion.com/unix_time.htm I got it is 1992 year, which is for sure not time of activity.

Minja
     
RankRankRank

Total Posts: 91

Joined 2012-10-12

PM

-Remember the definition for date_time types in FIT is the number of seconds since UTC 00:00 Dec31 1989. So a timestamp like 747547231 represents 08 Sept 2013 04:00:31 am (UTC).

HTH      
Rank

Total Posts: 8

Joined 2013-05-01

PM

Hi Shane,

yes, it was helpful, thanks.

I would like to return to problem with ride local time displaying. I tried to find local time zone from my fit file, but no success. You said it could be that this info does not exist in fit file, but I took a ride, uploaded it in http://www.strava.com and it shows ride local time. So, from fitSDK I receive utc, example, it is 18:07:45, but local time of ride was 05:07:45am and strava shows that, so it must be somewhere in fit file!

I jumped into fitSDK C# source code, but still could not find this info, probably still not understanding code good, but there is one method that could be key one for my problem:

public void Read(Stream inStream, MesgDefinition defnMesg)

This method goes through messages and try to find them in the stream. Correct? Could solution for problem be there?

Minja

     
RankRankRank

Total Posts: 91

Joined 2012-10-12

PM

If you want to analyze your .FIT file in more detail you could decode it using the C# SDK. I suggest you start with the sample decode program (cs\examples\examples.sln).

For me Strava already knows my location, even before I have entered any segments. I don't remember if I entered it when I created the account or they are guessing based on my ISP. It could be how they are converting UTC to localtime.      
Rank

Total Posts: 1

Joined 2013-11-09

PM

Hi Minja,

did you solve the problem?
Keep in mind the a web service like strava could use the browsers time in addition to the FIT file to correct the offset.

@Shane:
you said a device always records time in UTC. How can that be, when a device does not have any time zone information? at least I did not find any option in my garmin swim for setting a time zone!


minja - 30 September 2013 12:30 PM
Hi Shane,

yes, it was helpful, thanks.

I would like to return to problem with ride local time displaying. I tried to find local time zone from my fit file, but no success. You said it could be that this info does not exist in fit file, but I took a ride, uploaded it in http://www.strava.com and it shows ride local time. So, from fitSDK I receive utc, example, it is 18:07:45, but local time of ride was 05:07:45am and strava shows that, so it must be somewhere in fit file!

I jumped into fitSDK C# source code, but still could not find this info, probably still not understanding code good, but there is one method that could be key one for my problem:

public void Read(Stream inStream, MesgDefinition defnMesg)

This method goes through messages and try to find them in the stream. Correct? Could solution for problem be there?

Minja

     
RankRankRank

Total Posts: 91

Joined 2012-10-12

PM

-For the Garmin Swim utc_offset is initialized by Garmin Connect. After you have connected once, the device will use UTC timestamps in its .FIT output.      
Avatar
RankRankRankRank

Total Posts: 296

Joined 0

PM

This would possibly explain some really strange entries in the .FIT file taken from a brand new Garmin Swim watch.
But does that mean, that the time zone offset is NOT set at all, if you do not connect a Garmin Swim watch to Garmin Connect?

I've searched the Garmin Swim manual, but did not find any option to set a time zone in the watch manually.

Cheers,
OMB
     
RankRankRank

Total Posts: 91

Joined 2012-10-12

PM

It sounds like the Swim doesn't support setting the timezone. I think until you connect to Garmin Connect all the activity times would be expressed in 'system_time' (seconds since the battery was installed) so the timestamps would be small (< 0x10000000). If you get dates that appear to be before ~Dec 1997 this is what is happening.      
Rank

Total Posts: 2

Joined 2014-03-02

PM

I am examining the Activity FIT files from my Garmin Edge 800, and I cannot find any local timestamp information or time zone offset information.

Furthermore, if I change the time zone on my computer, all FIT files from my Edge 800 uploaded in Garmin Training Center show adjusted times, which correspond to the changed time zone on my computer.

Also, if I convert the FIT files with FitCSVTool, the timestamp information in the something_laps.csv, something_records.csv and something_sessions.csv files also corresponds to the changed time zone on my computer. (The timestamps in the something.csv file are not adjusted, they are still in seconds from 31-Dec-1989 00:00 UTC.)

So, both Garmin Training Center and FitCSVTool seem to use the computer's local time to adjust the FIT file's UTC timestamp information to a local time. I have read discussions on this forum that indicate that online tools such as Garmin Connect and Strava do the same, i.e., they use the local time of the PC from wich the FIT file is uploaded to calculate the offset from the timestamp information stored in the FIT file.

This leads me to the conclusion that the Garmin Edge 800 does not store any local timestamp information or time zone offset information in its Activity FIT files. I have seen discussions on this forum that suggest that this is indeed the case, but I have not found any confirmation. Can anyone confirm that the Garmin Edge 800 does indeed not store this information?

In addition to this, there must be a way to get the time zone information from co-ordinates. Does anyone know of an (online) tool that can do this?      
Avatar
RankRankRankRank

Total Posts: 296

Joined 0

PM

If I remember right, the edge800 does NOT store local start time.

Regarding online tools:
A while ago I was looking for one that can give you local time (= UTC + tzo + dst offset) for arbitrary time stamps and coordinates.
The only one I found was askgeo.com. Other services were restricted; they either don't consider dst or only work for the current date/time.
However askgeo.com isn't free any more.

If you find another online service, I'd be happy to learn about this.

Cheers,
OMB