Sponsored Content
Top Forums Shell Programming and Scripting Easiest way 2 convert the time YYYY-MM-DD HH:MM:SS.subsec to MJD - gAWK? Post 302436567 by drl on Monday 12th of July 2010 11:03:39 AM
Old 07-12-2010
Hi.

From a description at CPAN:
Code:
  use DateTime::Format::Epoch::MJD;

  my $dt = DateTime::Format::Epoch::MJD->parse_datetime( 53244 );
   # 2004-08-27T00:00:00

  DateTime::Format::Epoch::MJD->format_datetime($dt);
   # 53244

  my $formatter = DateTime::Format::Epoch::MJD->new();
  my $dt2 = $formatter->parse_datetime( 53244 );
   # 2004-08-27T00:00:00
  $formatter->format_datetime($dt2);
   # 53244

See DateTime::Format::Epoch::MJD - search.cpan.org

I have not tried this or any other method of these kinds of conversions, so I don't know what is easiest. This looks like a start, if nothing else.

Best wishes ... cheers, drl

( For the curious, see Julian day - Wikipedia, the free encyclopedia for an article on this. )
This User Gave Thanks to drl For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

how to convert the string YYYYMMDD into YYYY.MM.DD

how to convert the string YYYYMMDD into YYYY.MM.DD Please advice (1 Reply)
Discussion started by: spatra
1 Replies

2. Shell Programming and Scripting

How to convert DDMMYYYY to DD MONTH YYYY in Unix

Hi I am having date as a string in DDMMYYYY format(07082008) in a variable say cdate. I want to Convert it into DD Month YYYY format(7 August 2008). Could someone help. Thanks in Advance. (2 Replies)
Discussion started by: rspk_praveen
2 Replies

3. Shell Programming and Scripting

Convert DD-MMM-YYYY to MM-DD-YYYY

I have a file which has 100k+ records like this abc,05-JUN-1974,def,lkj,aaa def,11-SEP-1975,ghj,dis,dea I want to convert ex 05-JUN-1974 to 06/05/1974 Please help me with awk script to convert the whole file into MM-DD-YYYY Thank you! (2 Replies)
Discussion started by: nuthalapati
2 Replies

4. Shell Programming and Scripting

convert date format YYYYMMDD to MM/DD/YYYY

In my shell script i have a variable which stores date in the format of YYYYMMDD. Is there any way to format this value to MM/DD/YYYY. Thanks. (8 Replies)
Discussion started by: nasirgondal
8 Replies

5. Shell Programming and Scripting

Sed: zero-padding dates (or: convert d/m/yyyy to dd/mm/yyyy)

Hi all I have some pipe-separated data in the form: 5/12/2008 00:00:00|31/1/2009 00:00:00|SOMESTUFF|OTHERSTUFF 12/31/2008 00:00:00|15/1/2009 00:00:00|MORESTUFF|REMAININGSTUFF 1/1/1023 00:00:00|16/5/2047 00:00:00|THEREST|YETMORE I need to zero-pad the single-digit days and months, using... (3 Replies)
Discussion started by: jgrogan
3 Replies

6. Shell Programming and Scripting

convert d/m/yyyy to YYYY-MM-DD

My csv has data like this x,x,3452,2/18/1986,abc x,g,19711,1/24/1986,abc i want to replace date in the following format YYYY-mm-dd how do i convert using awk script ? (8 Replies)
Discussion started by: nuthalapati
8 Replies

7. Shell Programming and Scripting

Convert any date format into yyyy/mm/dd

How can I convert any user inputted date into yyyy/mm/dd ? For example user can input date one of the following 20120121 , 2012-01-21 ,01/21/2012,01/21/2012 etc But I need to convert any of the date entered by user into yyyy/mm/dd (2012/01/2012). Any suggestion. Thanks in advance this is... (1 Reply)
Discussion started by: ZeroHedge
1 Replies

8. Shell Programming and Scripting

Convert date column as yyyy/mm/dd format

Hi All, I have file like “April 10, 2013”,”raj” “April 29, 2013”,”raj1” Output : “2013/04/10”,”raj” “2013/04/29”,”raj1” Please help me how to do... (9 Replies)
Discussion started by: bmk
9 Replies

9. Shell Programming and Scripting

Bash to convert to m-d-yyyy

I am using bash that when run downloads a file a verifies that there is data in it. What I am not able to do is have a user enter a date in any format they wish and have it converted to m-d-yyyy. Thank you :). Bash printf " Welcome to NGS analysis, checking for new files and creating a... (2 Replies)
Discussion started by: cmccabe
2 Replies

10. UNIX for Advanced & Expert Users

How to convert mmm-yy to mm/dd/yyyy format in UNIX ?

How to convert mmm-yy to mm/dd/yyyy format in unix ? example: Jan-99 to 01/01/1999 Jan-00 to 01/01/2000 Jan-25 to 01/01/2025 Dec-99 to 01/12/1999 Dec-00 to 01/12/2000 Dec-25 to 01/12/2025 YY anything between 00-50 should be 2000-2050 YY anything between 51-99 should be 1951-1999 ... (2 Replies)
Discussion started by: gksenthilkumar
2 Replies
DateTime::Format::Builder::Parser::Quick(3pm)		User Contributed Perl Documentation	     DateTime::Format::Builder::Parser::Quick(3pm)

NAME
DateTime::Format::Builder::Parser::Quick - Use another formatter, simply SYNOPSIS
use DateTime::Format::Builder ( parsers => { parse_datetime => [ { Quick => 'DateTime::Format::HTTP' }, { Quick => 'DateTime::Format::Mail' }, { Quick => 'DateTime::Format::IBeat' }, ]}); is the same as: use DateTime::Format::HTTP; use DateTime::Format::Mail; use DateTime::Format::IBeat; use DateTime::Format::Builder ( parsers => { parse_datetime => [ sub { eval { DateTime::Format::HTTP->parse_datetime( $_[1] ) } }, sub { eval { DateTime::Format::Mail->parse_datetime( $_[1] ) } }, sub { eval { DateTime::Format::IBeat->parse_datetime( $_[1] ) } }, ]}); (These two pieces of code can both be found in the test suite; one as quick.t, the other as fall.t.) DESCRIPTION
"Quick" adds a parser that allows some shortcuts when writing fairly standard and mundane calls to other formatting modules. SPECIFICATION
"Quick" has two keys, one optional. The "Quick" keyword should have an argument of either an object or a class name. If it's a class name then the class is "use"d. The "method" keyword is optional with a default of "parse_datetime". It's either name of the method to invoke on the object, or a reference to a piece of code. In any case, the resultant code ends up looking like: my $rv = $Quick->$method( $date ); THANKS
See the main module's section. SUPPORT
Support for this module is provided via the datetime@perl.org email list. See http://lists.perl.org/ for more details. Alternatively, log them via the CPAN RT system via the web or email: http://perl.dellah.org/rt/dtbuilder bug-datetime-format-builder@rt.cpan.org This makes it much easier for me to track things and thus means your problem is less likely to be neglected. LICENCE AND COPYRIGHT
Copyright X Iain Truskett, 2003. All rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.000 or, at your option, any later version of Perl 5 you may have available. The full text of the licences can be found in the Artistic and COPYING files included with this module, or in perlartistic and perlgpl as supplied with Perl 5.8.1 and later. AUTHOR
Iain Truskett <spoon@cpan.org> SEE ALSO
"datetime@perl.org" mailing list. http://datetime.perl.org/ perl, DateTime, DateTime::Format::Builder perl v5.10.1 2010-03-14 DateTime::Format::Builder::Parser::Quick(3pm)
All times are GMT -4. The time now is 08:19 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy