The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
gawk and gensub ripat Shell Programming and Scripting 2 05-10-2008 12:20 PM
awk,gawk in bat file andrej Shell Programming and Scripting 0 05-09-2008 05:45 AM
strftime for JavaScript 1.2 (Default branch) iBot Software Releases - RSS News 0 04-28-2008 01:40 AM
gawk HELP sandeep_hi Shell Programming and Scripting 6 06-19-2006 05:56 AM
rs and ors in gawk ...???? moxxx68 Shell Programming and Scripting 2 10-05-2004 09:52 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 05-07-2008
Registered User
 

Join Date: Oct 2006
Location: Belgium
Posts: 171
gawk and strftime()

Strange behaviour of the strftime() function from gawk (3.1.5):

Code:
$ awk 'BEGIN{print strftime("%T", 3600)}'
> 02:00:00

$ awk 'BEGIN{print strftime("%T", 0)}'
> 01:00:00
Obviously something with DST but I can not figure out why? To me 3600 epoch seconds remains 01:00, DST or not.

From the gawk man pages:
Code:
strftime([format [, timestamp]])
                 Formats  timestamp  according to the specification in format.  The timestamp should be of the same form
                 as returned by systime().  If timestamp is missing, the current time of day  is  used.   If  format  is
                 missing,  a  default format equivalent to the output of date(1) is used.  See the specification for the
                 strftime() function in ANSI C for the format conversions that are guaranteed to be available.   A  pub‐
                 lic-domain  version  of  strftime(3)  and a man page for it come with gawk; if that version was used to
                 build gawk, then all of the conversions described in that man page are available to gawk.
Any idea?
Reply With Quote
Forum Sponsor
  #2  
Old 05-07-2008
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 4,298
DST is not UTC. If you mean METDST. It is one hour fast - exactly what you see. Plus you realize those values are for Dec 31 1969 - Jan 1 1970.

Midnight UTC is 1:00am DST. 1:00am UTC is 2:00am DST. What you see is correct.
Most systems are supposed to support the TZ variable. Play around with that
Code:
export TZ=MET-1METDST
date
export TZ=MET0
date
export TZ=ZZZ-19
date
Your gawk code should follow suit nicely.
Reply With Quote
  #3  
Old 05-07-2008
Registered User
 

Join Date: Oct 2006
Location: Belgium
Posts: 171
That was indeed the Time Zone that needed to be defined or canceled.

Code:
$ TZ=UTC awk 'BEGIN {print strftime("%T", 3600)}'
> 01:00:00
Thank you.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 12:18 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0