Sponsored Content
Full Discussion: Date conversion
Top Forums Shell Programming and Scripting Date conversion Post 302074080 by vgersh99 on Friday 19th of May 2006 01:11:57 PM
Old 05-19-2006
Code:
BEGIN {
  monN=split("JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC", months)
  for(i=1; i<=monN; i++) {
    months[months[i]]=i;
    delete months[i];
  }
}

function conv2mil(time,   tA, tAnum, pm_am) {
  tAnum=split(time, tA, ":")
  sec=substr(tA[tAnum], 1, length(tA[tAnum])-2)
  pm_am=toupper(substr(tA[tAnum], length(tA[tAnum])-1))
  hour= (pm_am ~ /^P./) ? tA[1] + 12 : tA[1]
  return (hour ":" tA[2] ":" sec)
}

{ printf("%s/%02d/%s %s\n",  $3, months[toupper($1)], $2, conv2mil($4) ) }

 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Date Conversion

Hello, I want to convert MM DD YYYY date format to MM-DD-YYYY format. For exemple: I have to convert Nov 28 2005 to 28-11-2005. Thenks for youf help. DAFI (2 Replies)
Discussion started by: dafidak
2 Replies

2. Shell Programming and Scripting

date conversion

Hi everybody: Could anybody tell me how I convert from a julian date, with shell comands, to gregorian. Thanks in advance. (2 Replies)
Discussion started by: tonet
2 Replies

3. Shell Programming and Scripting

date conversion

file1 E106,0,1/9/1993,0,E001,E003,A,45200,3766.667,21.730769 E108,0,2/3/1995,0,E001,E003,A,15000,1250,7.211538 E109,0,06-mar-07,0,E001,E001,A,78000,6500,37.5 E110,0,09-dec-2008,0,E001,E001,A,56000,4666.667,26.923077 E104,0,06/04/1994,0,E001,E003,A,95000,7916.667,45.673077... (14 Replies)
Discussion started by: charandevu
14 Replies

4. Shell Programming and Scripting

Date Conversion

Hi, Does anyone know (in KSH, CSH, SED or AWK), how to convert date text in a file from: EX: May232008 to: 05232008 Thanks, (3 Replies)
Discussion started by: jgrant746
3 Replies

5. Shell Programming and Scripting

Date conversion

Hi, I have the string YYYYMMDDHHMMSS like 20090801204150 and I need to convert it using the unix command date in the format: date "Saturday, 1 August 2009 20:40:59" All in one single Unix line if this is possible. What's the correct syntax? Steve Hagi (6 Replies)
Discussion started by: hagimeno
6 Replies

6. Shell Programming and Scripting

Conversion of date to Julian date

Hi Gurus, Need help in Conversion of date(2007-11-30) to Julian date(YYDDD)... '+%J' 2007-11-30 to 'YYDDD' Thanks (4 Replies)
Discussion started by: SeenuGuddu
4 Replies

7. UNIX for Dummies Questions & Answers

Date conversion in ab i

(string(8)) ((date("YYYYMMDD")) ((date("YYYY/MM/DD")) in.date_field_name)) (1 Reply)
Discussion started by: dr46014
1 Replies

8. Shell Programming and Scripting

Julian date to Calendar date conversion

Hi all, I require to convert julian date to normal calander date in unix for eg julian date=122 now i want corresponding calander date ---------------------------------------- gr8 if give very small command/script and please explain the steps as well(imp) Thanks ... (3 Replies)
Discussion started by: RahulJoshi
3 Replies

9. Shell Programming and Scripting

Date conversion

Trying to convert dates using a Perl Script but it has to accept formats like 3 letter month, day and year like Nov 02 2010 or 1/4/11 or 21 Feb 2011 and have it convert to something like October 20, 2011. Any ideas? (2 Replies)
Discussion started by: reduxeffect81
2 Replies

10. UNIX for Beginners Questions & Answers

Date conversion

Hi , we have a string with yyyymmdd format . how to know which date it is ? example:20120712-->sunday 20150228-->saturday 20140431-->invalid please suggest commands which work on below os : SunOS 5.10 shell: bash shell Thanks, Srinath. (10 Replies)
Discussion started by: srinadhreddy27
10 Replies
libapache2-mod-perl2-2.0.7::docs::api::APR::Brigade(3pm)User Contributed Perl Documentatiolibapache2-mod-perl2-2.0.7::docs::api::APR::Brigade(3pm)

NAME
APR::Brigade - Perl API for manipulating APR Bucket Brigades Synopsis use APR::Brigade (); $bb = APR::Brigade->new($r->pool, $c->bucket_alloc); $ba = $bb->bucket_alloc(); $pool = $bb->pool; $bb->insert_head($b); $bb->insert_tail($b); $b_first = $bb->first; $b_last = $bb->last; $b_prev = $bb->prev($b_last); $b_next = $bb->next($b); $bb2 = APR::Brigade->new($r->pool, $c->bucket_alloc); $bb1->concat($bb2); $len = $bb->flatten($data); $len = $bb2->flatten($data, $wanted); $len = $bb->length; $bb3 = $bb->split($b_last); last if $bb->is_empty(); $bb->cleanup(); $bb->destroy(); Description "APR::Brigade" allows you to create, manipulate and delete APR bucket brigades. API
"APR::Brigade" provides the following functions and/or methods: "cleanup" Empty out an entire bucket brigade: $bb->cleanup; obj: $bb ( "APR::Brigade object" ) The brigade to cleanup ret: no return value since: 2.0.00 This method destroys all of the buckets within the bucket brigade's bucket list. This is similar to "destroy()", except that it does not deregister the brigade's "pool()" cleanup function. Generally, you should use "destroy()". This function can be useful in situations where you have a single brigade that you wish to reuse many times by destroying all of the buckets in the brigade and putting new buckets into it later. "concat" Concatenate brigade $bb2 onto the end of brigade $bb1, leaving brigade $bb2 empty: $bb1->concat($bb2); obj: $bb1 ( "APR::Brigade object" ) The brigade to concatenate to. arg1: $bb2 ( "APR::Brigade object" ) The brigade to concatenate and empty afterwards. ret: no return value since: 2.0.00 "destroy" destroy an entire bucket brigade, includes all of the buckets within the bucket brigade's bucket list. $bb->destroy(); obj: $bb ( "APR::Brigade object" ) The bucket brigade to destroy. ret: no return value excpt: "APR::Error" since: 2.0.00 "is_empty" Test whether the bucket brigade is empty $ret = $bb->is_empty(); obj: $bb ( "APR::Brigade object" ) ret: $ret ( boolean ) since: 2.0.00 "first" Return the first bucket in a brigade $b_first = $bb->first; obj: $bb ( "APR::Brigade object" ) ret: $b_first ( "APR::Bucket object" ) The first bucket in the bucket brigade $bb. "undef" is returned if there are no buckets in $bb. since: 2.0.00 "flatten" Get the data from buckets in the bucket brigade as one string $len = $bb->flatten($buffer); $len = $bb->flatten($buffer, $wanted); obj: $bb ( "APR::Brigade object" ) arg1: $buffer ( SCALAR ) The buffer to fill. All previous data will be lost. opt arg2: $wanted ( number ) If no argument is passed then all data will be returned. If $wanted is specified -- that number or less bytes will be returned. ret: $len ( number ) How many bytes were actually read. $buffer gets populated with the string that is read. It will contain an empty string if there was nothing to read. since: 2.0.00 excpt: "APR::Error" "insert_head" Insert a list of buckets at the front of a brigade $bb->insert_head($b); obj: $bb ( "APR::Brigade object" ) Brigade to insert into arg1: $b ( "APR::Bucket object" ) the bucket to insert. More buckets could be attached to that bucket. ret: no return value since: 2.0.00 "insert_tail" Insert a list of buckets at the end of a brigade $bb->insert_tail($b); obj: $bb ( "APR::Brigade object" ) Brigade to insert into arg1: $b ( "APR::Bucket object" ) the bucket to insert. More buckets could be attached to that bucket. ret: no return value since: 2.0.00 "last" Return the last bucket in the brigade $b_last = $bb->last; obj: $bb ( "APR::Brigade object" ) ret: $b_last ( "APR::Bucket object" ) The last bucket in the bucket brigade $bb. "undef" is returned if there are no buckets in $bb. since: 2.0.00 "length" Return the total length of the data in the brigade (not the number of buckets) $len = $bb->length; obj: $bb ( "APR::Brigade object" ) ret: $len ( number ) since: 2.0.00 "new" my $nbb = APR::Brigade->new($p, $bucket_alloc); my $nbb = $bb->new($p, $bucket_alloc); obj: $bb ( "APR::Brigade object or class" ) arg1: $p ( "APR::Pool object" ) arg2: $bucket_alloc ( "APR::BucketAlloc object" ) ret: $nbb ( "APR::Brigade object" ) a newly created bucket brigade object since: 2.0.00 Example: Create a new bucket brigade, using the request object's pool: use Apache2::Connection (); use Apache2::RequestRec (); use APR::Brigade (); my $bb = APR::Brigade->new($r->pool, $r->connection->bucket_alloc); "bucket_alloc" Get the bucket allocator associated with this brigade. my $ba = $bb->bucket_alloc(); obj: $bb ( "APR::Brigade object or class" ) ret: $ba ( "APR::BucketAlloc object" ) since: 2.0.00 "next" Return the next bucket in a brigade $b_next = $bb->next($b); obj: $bb ( "APR::Brigade object" ) arg1: $b ( "APR::Bucket object" ) The bucket after which the next bucket $b_next is located ret: $b_next ( "APR::Bucket object" ) The next bucket after bucket $b. "undef" is returned if there is no next bucket (i.e. $b is the last bucket). since: 2.0.00 "pool" The pool the brigade is associated with. $pool = $bb->pool; obj: $bb ( "APR::Brigade object" ) ret: $pool ( "APR::Pool object" ) since: 2.0.00 The data is not allocated out of the pool, but a cleanup is registered with this pool. If the brigade is destroyed by some mechanism other than pool destruction, the destroying function is responsible for killing the registered cleanup. "prev" Return the previous bucket in the brigade $b_prev = $bb->prev($b); obj: $bb ( "APR::Brigade object" ) arg1: $b ( "APR::Bucket object" ) The bucket located after bucket $b_prev ret: $b_prev ( "APR::Bucket object" ) The bucket located before bucket $b. "undef" is returned if there is no previous bucket (i.e. $b is the first bucket). since: 2.0.00 "split" Split a bucket brigade into two, such that the given bucket is the first in the new bucket brigade. $bb2 = $bb->split($b); obj: $bb ( "APR::Brigade object" ) The brigade to split arg1: $b ( "APR::Bucket object" ) The first bucket of the new brigade ret: $bb2 ( "APR::Brigade object" ) The new brigade. since: 2.0.00 This function is useful when a filter wants to pass only the initial part of a brigade to the next filter. Example: Create a bucket brigade with three buckets, and split it into two brigade such that the second brigade will have the last two buckets. my $bb1 = APR::Brigade->new($r->pool, $c->bucket_alloc); my $ba = $c->bucket_alloc(); $bb1->insert_tail(APR::Bucket->new($ba, "1")); $bb1->insert_tail(APR::Bucket->new($ba, "2")); $bb1->insert_tail(APR::Bucket->new($ba, "3")); $bb1 now contains buckets "1", "2", "3". Now do the split at the second bucket: my $b = $bb1->first; # 1 $b = $bb1->next($b); # 2 my $bb2 = $bb1->split($b); Now $bb1 contains bucket "1". $bb2 contains buckets: "2", "3" See Also mod_perl 2.0 documentation. Copyright mod_perl 2.0 and its core modules are copyrighted under The Apache Software License, Version 2.0. Authors The mod_perl development team and numerous contributors. perl v5.14.2 2011-02-08 libapache2-mod-perl2-2.0.7::docs::api::APR::Brigade(3pm)
All times are GMT -4. The time now is 04:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy