HIToC | 21 Sep 2006 22:36
Picon
Favicon

getdate(3) - format date

Hello list,
I am using the getdate(3) function to convert a string date in its tm structure, but
I have tried several formats of string-dates and it always returns a NULL pointer.

All this dates I suppose invalid for the getdate(3):
Fri, 19 Nov 82 16:14:55 EST
Wed, 20 Sep 2006 15:03:53 GMT
Thu, 21 Sep 2006 08:59:25 +0400
19 Sep 2006 15:52:25 -0700
19 Sep 2006 15:52:25 EST

Do you know what are the correct string formats for this function and if under
Unix there are routines to read ascii string dates such in mail text messages
or USENET articles?

Thank you in advance
HIToC
--

-- 
With regards,

					HIToC
					hitoc_mail <at> yahoo.it
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Steve Graegert | 22 Sep 2006 09:28
Picon

Re: getdate(3) - format date

On 9/21/06, HIToC <hitoc_mail <at> yahoo.it> wrote:
> Hello list,
> I am using the getdate(3) function to convert a string date in its tm structure, but
> I have tried several formats of string-dates and it always returns a NULL pointer.
>
> All this dates I suppose invalid for the getdate(3):
> Fri, 19 Nov 82 16:14:55 EST
> Wed, 20 Sep 2006 15:03:53 GMT
> Thu, 21 Sep 2006 08:59:25 +0400
> 19 Sep 2006 15:52:25 -0700
> 19 Sep 2006 15:52:25 EST

Sure, they are valid, but getdate(3) requires a template file to be
present, with each line in the file representing a date format to
parse.  From getdate(3):

     User-supplied templates are used to parse and interpret  the
     input  string.  The templates are  text files created by the
     user and identified via the  environment  variable  DATEMSK.
     Each  line  in  the  template  represents an acceptable date
     and/or time specification using   conversion  specifications
     similar  to  those  used  by  strftime(3) and strptime(3).

Consider the following example which illustrates the usage of getdate(3)

--- BEGIN script ---

#!/bin/sh
#
# create template file
(Continue reading)

HIToC | 22 Sep 2006 22:40
Picon
Favicon

Re: getdate(3) - format date

Yes Steve!
The problem was the absence of both DATEMSK and the template file becouse
the getdate_err was setted to 1.
Now I have tried your script but it does not exports the DATEMSK to the
environment: if next the execution of the script I type
echo $DATEMSK
it prints nothing.
If I execute the C program from the script it runs but the getdate_err said that there
is no line in the template that matches the input [error 7].
I believe that the getdate solution is very unportable.
Thanks anyway!

On Friday 22 September 2006 09:28, Steve Graegert wrote:
> On 9/21/06, HIToC <hitoc_mail <at> yahoo.it> wrote:
> > Hello list,
> > I am using the getdate(3) function to convert a string date in its tm
> > structure, but I have tried several formats of string-dates and it always
> > returns a NULL pointer.
> >
> > All this dates I suppose invalid for the getdate(3):
> > Fri, 19 Nov 82 16:14:55 EST
> > Wed, 20 Sep 2006 15:03:53 GMT
> > Thu, 21 Sep 2006 08:59:25 +0400
> > 19 Sep 2006 15:52:25 -0700
> > 19 Sep 2006 15:52:25 EST
>
> Sure, they are valid, but getdate(3) requires a template file to be
> present, with each line in the file representing a date format to
> parse.  From getdate(3):
>
(Continue reading)

Henry Margies | 25 Sep 2006 10:53
Picon
Picon

Re: getdate(3) - format date

Hello HIToc,

On Fri, 2006-09-22 at 22:40 +0200, HIToC wrote:
> Now I have tried your script but it does not exports the DATEMSK to the
> environment: if next the execution of the script I type
> echo $DATEMSK it prints nothing.

How did you execute the script? In order to have the variable exported,
you have to source this shell script. Try something like this:

. ./script

or

source ./script

Best regards,

Henry

-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

HIToC | 26 Sep 2006 19:27
Picon
Favicon

Re: getdate(3) - format date

Hello Henry,

	I have used "sh": sh script
But using ./script has the same problem: DATEMSK is not exported.

Thank you for the emails
HIToC

On Monday 25 September 2006 10:53, Henry Margies wrote:
> Hello HIToc,
>
> On Fri, 2006-09-22 at 22:40 +0200, HIToC wrote:
> > Now I have tried your script but it does not exports the DATEMSK to the
> > environment: if next the execution of the script I type
> > echo $DATEMSK it prints nothing.
>
> How did you execute the script? In order to have the variable exported,
> you have to source this shell script. Try something like this:
>
> . ./script
>
> or
>
> source ./script
>
>
>
> Best regards,
>
> Henry
(Continue reading)

Kirkwood, David A | 26 Sep 2006 21:25
Picon
Favicon

(unknown)

I have an application that works perfectly in a 32 bit environment, but
does not in a 64 bit environment. I believe

The problem has to do with a structure defined as

            Struct  x {

                        Short aaa
                        Short bbb
                        Char something[12]
                        Long lll
                        Long mmm
            }

Sorry about the capitalization.... I'm condemned to using exchange /
outlook.

After the program starts, I look at the  short variables above and they
are initialized to hex 2020 (both) which are spaces if they were
characters. Since this structure is initialized with a pointer to is (
and its components ) I wonder if in the 64 bit environment I have to
manually pad out the size(s) to even 64 bit boumderies?

Help

David 

-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo <at> vger.kernel.org
(Continue reading)

Kelly Burkhart | 27 Sep 2006 16:19

Re: Struct padding (was blank subject)

On 9/26/06, Kirkwood, David A <DAVID.A.KIRKWOOD <at> saic.com> wrote:
> I have an application that works perfectly in a 32 bit environment, but
> does not in a 64 bit environment. I believe
>
> The problem has to do with a structure defined as
>
>             Struct  x {
>
>                         Short aaa
>                         Short bbb
>                         Char something[12]
>                         Long lll
>                         Long mmm
>             }
>
> Sorry about the capitalization.... I'm condemned to using exchange /
> outlook.
>
> After the program starts, I look at the  short variables above and they
> are initialized to hex 2020 (both) which are spaces if they were
> characters. Since this structure is initialized with a pointer to is (
> and its components ) I wonder if in the 64 bit environment I have to
> manually pad out the size(s) to even 64 bit boumderies?

How are you initializing the structure?

You usually shouldn't depend on the layout of structures.  There are
cases in which it is necessary, but it is usually better to avoid.  If
you're trying to write the memory region of this structure to a file
on a 32-bit machine and read it on a 64-bit machine it  would be
(Continue reading)

Henry Margies | 28 Sep 2006 09:38
Picon
Picon

Re: getdate(3) - format date

On Tue, 2006-09-26 at 19:27 +0200, HIToC wrote:
> Hello Henry,
> 
> 	I have used "sh": sh script
> But using ./script has the same problem: DATEMSK is not exported.
> 
> Thank you for the emails
> HIToC
> 

If you execute a script via sh script.sh or ./script.sh it is executed
in a sub shell. So every exported variable is only set in all sub-sub
shells.

Try this script to see what I mean

#!/bin/sh

export V=Test
echo $V

Now execute it in a sub shell:

sh script.sh
echo $V

and execute it in the current shell (via sourcing it)

. ./script.sh
echo $V
(Continue reading)


Gmane