Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
156 user(s) are online (122 user(s) are browsing Forums)

Members: 1
Guests: 155

amig_os, more...

Headlines

 
  Register To Post  

Annoying ParseDate() function
Supreme Council
Supreme Council


See User information
Anyone got an example of using ParseDate(), I just can't get it to work.

void DateToDate(STRPTR datestruct DateStamp *dateStamp)
{
 
STRPTR pattern = (STRPTR)"%Y%m%d-%H.%M";
 
 
struct Hook datehook;
 
datehook.h_Entry = (HOOKFUNC)DateToDateHook;
 
datehook.h_SubEntry NULL;
 
datehook.h_Data date;
 
 
ILocale->ParseDate(LocaledateStamppattern, &datehook);
..
..
}

char DateToDateHook(struct Hook *hookstruct Locale *localeAPTR mu)
{
 
// what the hell am I suppsoed to do here?!?
}


Edited by orgin on 2010/1/16 18:44:04
Edited by orgin on 2010/1/16 19:02:05
Edited by orgin on 2010/1/16 19:04:17
Edited by orgin on 2010/1/16 19:46:22
Vacca foeda. Sum, ergo edo

Mr Bobo Cornwater
Go to top
Re: Annoying ParseDate() function
Not too shy to talk
Not too shy to talk


See User information

Go to top
Re: Annoying ParseDate() function
Supreme Council
Supreme Council


See User information
@thomas

Thanks.

Seems it's not possible to parse something that looks like:

"20010116-20.39"
"%Y%m%d-%H.%M"

(I just get random garbage from it)

your date format works though

"2001/01/16-20.39"
"%Y/%m/%d-%H.%M"

Seems like I'll have to insert some junk characters manually.

Vacca foeda. Sum, ergo edo

Mr Bobo Cornwater
Go to top
Re: Annoying ParseDate() function
Not too shy to talk
Not too shy to talk


See User information
@orgin

Quote:

Seems it's not possible to parse something that looks like:

"20010116-20.39"
"%Y%m%d-%H.%M"



Yes, I got this problem, too. That's why I added the / to the format.

%Y probably reads the entire number until the first non-numeric character appears. Perhaps you can specify something like %4Y or %.4Y. I am not so familar with this scanf-like stuff.

Quote:
I just get random garbage from it


You should check the return value. If ParseDate returns false, it has not found a result.

Go to top
Re: Annoying ParseDate() function
Supreme Council
Supreme Council


See User information
@thomas

I solved it by creating a new string from the old, inserting "/" where needed. So I'll fly with that.

Vacca foeda. Sum, ergo edo

Mr Bobo Cornwater
Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2023 The XOOPS Project