- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- display time described by STRING, not NOW
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-16-2010 03:32 AM
тАО09-16-2010 03:32 AM
like this in Linux:
# date -d 01/03/2010 +%j
003
# date -d 12/31/2010 +%j
365
Solved! Go to Solution.
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-16-2010 03:48 AM
тАО09-16-2010 03:48 AM
Re: display time described by STRING, not NOW
# date +%j
259
but not for a given date period..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-16-2010 04:03 AM
тАО09-16-2010 04:03 AM
Re: display time described by STRING, not NOW
You can install the 'Date::Calc' module from CPAN and use its 'Day_of_Year' function.
http://search.cpan.org/~stbey/Date-Calc-6.3/lib/Date/Calc.pod
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-16-2010 04:09 AM
тАО09-16-2010 04:09 AM
Re: display time described by STRING, not NOW
http://hpux.connect.org.uk/hppd/hpux/Gnu/sh_utils-2.0/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-16-2010 06:04 AM
тАО09-16-2010 06:04 AM
Re: display time described by STRING, not NOW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-16-2010 06:40 AM
тАО09-16-2010 06:40 AM
SolutionWell, rolling your own isn't hard:
# cat /.showday
#!/usr/bin/perl
use strict;
use warnings;
use Time::Local;
use POSIX qw( strftime );
my ( $mon, $day, $year ) = split m{/}, shift;
my $time = timelocal( 0, 0, 0, $day, $mon - 1, $year );
print strftime( "%j\n", localtime($time) );
1;
...run as:
# ./showday 09/16/2010
259
# ./showday 12/31/2010
365
# ./showday 12/31/2012
366
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-16-2010 10:44 PM
тАО09-16-2010 10:44 PM
Re: display time described by STRING, not NOW
Thaks for great solutions,
the only thing I tried to learn "strftime" is inside a C class header "time.h" ,
I cannot use it directly in command line,but in Perl with POSIX module,
Am I right ??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-16-2010 11:25 PM
тАО09-16-2010 11:25 PM
Re: display time described by STRING, not NOW
>I cannot use it directly in command line but in Perl with POSIX module
When you use "date +" you are using strftime(3) but only with NOW.
If you want use other times, you are left with perl or a language like C or C++.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-17-2010 03:41 AM
тАО09-17-2010 03:41 AM
Re: display time described by STRING, not NOW
> the only thing I tried to learn "strftime" is inside a C class header "time.h" ,
I cannot use it directly in command line,but in Perl with POSIX module,
Am I right ??
Yes, you can't use it in a shell script, but Perl's POSIX module provides hooks into the 'libc' library so you have the support I offered. The POSIX module offers access nearly all of the standard POSIX 1003.1 identifiers.
Regards!
...JRF...