3 ==============================================================================
5 This file is part of GNSSTk, the ARL:UT GNSS Toolkit.
7 The GNSSTk is free software; you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as published
9 by the Free Software Foundation; either version 3.0 of the License, or
12 The GNSSTk is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public
18 License along with GNSSTk; if not, write to the Free Software Foundation,
19 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
21 This software was developed by Applied Research Laboratories at the
22 University of Texas at Austin.
23 Copyright 2004-2022, The Board of Regents of The University of Texas System
25 ==============================================================================
27 ==============================================================================
29 This software was developed by Applied Research Laboratories at the
30 University of Texas at Austin, under contract to an agency or agencies
31 within the U.S. Department of Defense. The U.S. Government retains all
32 rights to use, duplicate, distribute, disclose, or release this software.
34 Pursuant to DoD Directive 523024
36 DISTRIBUTION STATEMENT A: This software has been approved for public
37 release, distribution is unlimited.
39 ==============================================================================
48 def main(args=sys.argv[1:]):
49 program_description = (
'Converts from a given input time specification to '
50 'other time formats. Include the quotation marks. '
51 'All year values are four digit years. '
52 'Example: $ python gnsstk_timeconvert.py -f "158 200" ')
53 parser = argparse.ArgumentParser(description=program_description)
55 group = parser.add_mutually_exclusive_group()
56 group.add_argument(
'-A',
'--ansi', help=
'\"ANSI-Second\"')
57 group.add_argument(
'-c',
'--civil',
58 help=
'\"Month(numeric) DayOfMonth Year Hour:Minute:Second\"')
59 group.add_argument(
'-R',
'--rinex',
60 help=
'\"Year(2-digit) Month(numeric) DayOfMonth Hour Minute Second\"')
61 group.add_argument(
'-o',
'--ews', help=
'\"GPSEpoch 10bitGPSweek SecondOfWeek\"')
62 group.add_argument(
'-f',
'--ws', help=
'\"FullGPSWeek SecondOfWeek\"')
63 group.add_argument(
'-w',
'--wz', help=
'\"FullGPSWeek Zcount\"')
64 group.add_argument(
'--z29', help=
'\"29bitZcount\"')
65 group.add_argument(
'-Z',
'--z32', help=
'\"32bitZcount\"')
66 group.add_argument(
'-j',
'--julian', help=
'\"JulianDate\"')
67 group.add_argument(
'-m',
'--mjd', help=
'\"ModifiedJulianDate\"')
68 group.add_argument(
'-u',
'--unixtime', help=
'\"UnixSeconds UnixMicroseconds\"')
69 group.add_argument(
'-y',
'--doy', help=
'\"Year DayOfYear SecondsOfDay\"')
71 parser.add_argument(
'-F',
'--output_format', help=
'Time format to use on output')
73 parser.add_argument(
'-a',
'--add_offset', type=int, nargs=
'+',
74 help=
'add NUM seconds to specified time')
75 parser.add_argument(
'-s',
'--sub_offset', type=int, nargs=
'+',
76 help=
'subtract NUM seconds to specified time')
77 args = parser.parse_args(args)
82 'civil' :
'%m %d %Y %H:%M:%f',
83 'rinex' :
'%y %m %d %H %M %S',
97 input_time = getattr(args, key)
98 if input_time
is not None:
102 except gnsstk.InvalidRequest:
103 raise gnsstk.InvalidRequest(
'Input could not be parsed.'
104 '\nCheck the formatting and ensure that the input is both valid and in quotes.'
105 '\nAlso check if the time is too early/late for these formats.')
113 if args.add_offset
is not None:
114 for t
in args.add_offset:
115 ct.addSeconds(float(t))
116 if args.sub_offset
is not None:
117 for t
in args.sub_offset:
118 ct.addSeconds(-float(t))
120 if args.output_format
is not None:
125 return spacing + str.ljust(31)
129 print left_align(
'Month/Day/Year H:M:S'),
132 print left_align(
'Modified Julian Date'),
135 print left_align(
'GPSweek DayOfWeek SecOfWeek'),
138 print left_align(
'FullGPSweek Zcount'),
141 print left_align(
'Year DayOfYear SecondOfDay'),
144 print left_align(
'Unix: Second Microsecond'),
147 print left_align(
'Zcount: 29-bit (32-bit)'),
153 if __name__ ==
'__main__':