How to read & write date stored in text file?

Login to reply to this topic.
Fri, 2007-08-17 07:36
Joined: 2007-07-24
Forum posts: 24

Hello,

I'm developing one appliaction. I want to make this application as trial version for 5 days.

I'm trying to use date compare logic.

At the time of installation, i'm creating one Text file which remains on C:\ drive.
Same time i'm accessing current date (installation date) using

TTime time;
           time.HomeTime();

Now i want to store date in Text file. How to write this date in file?

                RFs session;
        RFile f;
               
        User::LeaveIfError( session.Connect());
        TFileText tfile;

        TInt err = f.Open(session, RemaingTime, EFileRead ) ;
        if( err == KErrNotFound)
        {
             f.Create(session,RemaingTime, EFileWrite );
              
                    TTime installation_date;
            installation_date.HomeTime();

//                  HOW TO WRITE THIS DATE IN FILE??               
//                 ADD 5 days in this date
                  
                    TBuf<32> buffer;

            _LIT(KFormatDate,"%d  %d  %d ");
                 
            buffer.Format(KFormatDate,dateTime.Day()+5,TInt(dateTime.Month()),dateTime.Year());
               
//          f.Write(buffer);        //How to convert TBuf to TDesC
        }
        else if ( err == KErrNone )
        {
             tfile.Set(f);
             TBuf<30> expiry_date;
               
              while( tfile.Read(expiry_date) != KErrEof )
              {
                   TTime current_time;
                   current_time.HomeTime();
       
//                         HOW TO COMPARE "expiry_date" & "current_date"??       
//                         IF match (or current date greater than expiry_date), close
//                         application
              }
        }

Whenever next time user opens application, i'm again accessing current date & comapring this with date stored in text file.

So please let me know how to write date in text file &


Fri, 2007-08-17 07:57
Joined: 2004-05-21
Forum posts: 285
Re: How to read & write date stored in text file?

>>HOW TO WRITE THIS DATE IN FILE??
Convert datetime to descriptor using TTime::FormatL and use RFile:Write to write to a file.

>>HOW TO COMPARE "expiry_date" & "current_date"??
Use TTime::Set (For this to work you should store in a specific format. check out help for more info) to set the datetime read from file which is in the form of descriptor. Use += and >= operators of TTime to add interval and compare.

Cheers,
Sri

Fri, 2007-08-17 09:18
Joined: 2007-03-07
Forum posts: 5
Re: How to read & write date stored in text file?

Or you can simply use fopen, fprintf, etc. They are supported even in OS 6.

Tue, 2008-05-13 09:15
Joined: 2008-02-12
Forum posts: 37
Re: How to read & write date stored in text file?

Did you succed in making a trial version? I am planning to do a trial version for our product Digital lotus

http://www.softwaremarket.nokia.com/?action=productDetails&pID=5124&pmsid=283&lang=en¤cy=USD

without using Openbit.

  • Login to reply to this topic.