Please help with dates and other items...

Just starting out? Need help? Post your questions and find answers here.
mearrin69
User
User
Posts: 10
Joined: Thu Jun 24, 2004 10:44 pm
Location: Vancouver, WA

Please help with dates and other items...

Post by mearrin69 »

Hi all,
I've had PureBasic for a while and have done a few things with it but am far from adequate with it, let alone proficient. :) I'm working on an program to translate some downloaded tabular material from HTML to CSV format for integration into a database. This data is TV listing information and each file represents a three-hour span, providing program information for each of 100+ channels during that period.

I have a basic framework going but my first challenge seems to be working with dates. Each raw data file (again, HTML, but that doesn't matter for this question) is named something like "ZCGrid.do@fromTimeInMillis=1204023600000". I'd like to take that millisecond figure and convert it into a useable date, both for the output file and for the title inside the CSV file.

If I take the filename above as a string (sInFile) and perform "Right(sInFile, 13)" I get the string "1204023600000". But I'm not sure what to do with it. If I use the Val() function and try to put it into an integer the value changes (because the integer type isn't big enough I assume). If I use the ValD() function and put it into a double I see that the value is correct but that value then does not seem to work with the FormatDate function:

Code: Select all

       tmpa.d = ValD(Right(sInFile, 13))
       tmpb.s = FormatDate("%yyyy-%mm-%dd %hh:%ii:%ss", tmpa)
I can't find in the documentation what type the Date functions expect to be handed. Am I missing something. Any suggestions on how to make this work. I'm sure this is terribly n00bish and I'm just missing something painfully obvious here. Thanks for any help!

BTW, the vagueish title is because I'm assuming I'll run into other stuff and don't want to spam the forums with multiple threads...if that's the wrong concept for these forums please let me know. :)
M
cas
Enthusiast
Enthusiast
Posts: 597
Joined: Mon Nov 03, 2008 9:56 pm

Re: Please help with dates and other items...

Post by cas »

Date function returns number of seconds, you have milliseconds here so divide by 1000 or ignore last 3 digits:

Code: Select all

sInFile.s="ZCGrid.do@fromTimeInMillis=1204023600000"

tmpa = Val(Left(Right(sInFile, 13),10))
tmpb.s = FormatDate("%yyyy-%mm-%dd %hh:%ii:%ss", tmpa)
Debug tmpb.s
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Please help with dates and other items...

Post by ts-soft »

error by me
Last edited by ts-soft on Mon Sep 20, 2010 4:13 pm, edited 1 time in total.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Re: Please help with dates and other items...

Post by Trond »

The Date library allows for the manipulation of Date and Time from 1970 up to 2038 using the unix method (i.e. the number of seconds elapsed since the 1st of January 1970).
mearrin69
User
User
Posts: 10
Joined: Thu Jun 24, 2004 10:44 pm
Location: Vancouver, WA

Re: Please help with dates and other items...

Post by mearrin69 »

Oh. Duh. Well, that *was* indeed n00bish. Thanks for setting me straight!
M
Post Reply