TheTVDB.com

Online TV Database
It is currently Sat May 18, 2013 11:29 pm

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Sat May 12, 2012 5:11 am 
Offline

Joined: Sat May 12, 2012 4:52 am
Posts: 3
Location: South Africa
I am currently developing an application for Windows Vista/Seven to manage digital recordings of my favourite TV shows. For the most part, I've nailed down the XML parsing, with one exception:

the "lastupdated" field within the XML returned by GetSeries.php. Is this nothing more than a simple Integer value, or is there some form of encoding involved within the binary structure of this field?

In essense, what I'm asking for is whether or not it is possible to convert the value of "lastupdated" into a Date/Time (TDateTime type in Delphi 2010)?
Attachment:
File comment: "lastupdated" value
Image - lastupdated value.jpg
Image - lastupdated value.jpg [ 83.65 KiB | Viewed 427 times ]


Top
 Profile  
 
PostPosted: Sat May 12, 2012 9:54 am 
Offline
Site Moderator

Joined: Sat Oct 16, 2010 5:48 pm
Posts: 1089
Location: England
Looking at that value, is suspect it is a unix timestamp. (number of seconds since 1/1/1970) not 100% sure though but I'd say it's a safe bet.

_________________
---

Please watch this video to help LSU Computer Society try to win the RBS ESSA society competition! http://youtu.be/8JrhmoSXLXw - only 1:36min

Thanks :D


Top
 Profile  
 
PostPosted: Sat May 12, 2012 10:53 am 
Offline

Joined: Tue Apr 26, 2011 5:56 am
Posts: 1191
Epoch seconds? :D

_________________
MAL | trakt

Image


Top
 Profile  
 
PostPosted: Sat May 12, 2012 12:03 pm 
Offline
Site Admin

Joined: Tue Mar 13, 2007 10:16 pm
Posts: 1900
Location: Canada
It's just a standard mySQL timestamp which I think is the same as a unix timestamp(Edit: It is). I don't know Delphi but it should have a function that can parse it just fine I'd be shocked if it didn't TBH.

_________________
Please don't PM me. Post in the forums instead unless there is a very good reason for a PM or I won't answer you.


Top
 Profile  
 
PostPosted: Sat May 12, 2012 11:59 pm 
Offline

Joined: Sat May 12, 2012 4:52 am
Posts: 3
Location: South Africa
thanks for the information. I'll investigate converting the value from a Unix timestampe into a TDateTime value, and see if that works.

I'll post back if I need more info.


Top
 Profile  
 
PostPosted: Sun May 13, 2012 12:23 am 
Offline

Joined: Sat May 12, 2012 4:52 am
Posts: 3
Location: South Africa
Really, thanks to all who replied to my query. It put me in the right direction towards a solution.

I discovered the following functions (any other Delphi developers here are welcome to copy can paste the code for their own use):

Quote:
const
// Sets UnixStartDate to TDateTime of 01/01/1970
UnixStartDate: TDateTime = 25569.0;

function DateTimeToUnix(ConvDate: TDateTime): Longint;
begin
Result := Round((ConvDate - UnixStartDate) * 86400);
end;

function UnixToDateTime(USec: Longint): TDateTime;
begin
Result := (Usec / 86400) + UnixStartDate;
end;


So I changed my code from this:
Quote:
EditDetailsUpdated.Text := IntToStr(ASeriesItem.Properties.Lastupdated);


to this:
Quote:
EditDetailsUpdated.Text := FormatDateTime('dd mmmm yyyy, hh:nn', UnixToDateTime(ASeriesItem.Properties.Lastupdated));


and my Properties Form now gives me a more "user friendly" display of the "lastupdated" field.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group