github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/docs/commands/datetime.md (about)

     1  # `datetime`
     2  
     3  > A date and/or time conversion tool (like `printf` but for date and time values)
     4  
     5  ## Description
     6  
     7  While `date` is a standard UNIX tool, it's syntax can vary from Linux to macOS.
     8  `datetype` aims to be a cross platform alternative while also offering a range
     9  of saner syntax options too.
    10  
    11  The syntax for `datetime` is modelled from date and time libraries from various
    12  popular programming languages.
    13  
    14  ## Usage
    15  
    16  Pass date/time value as a parameter:
    17  
    18  ```
    19  datetime --in "format" --out "format" --value "date/time" -> <stdout>
    20  ```
    21  
    22  Read date/time value from STDIN:
    23  
    24  ```
    25  <stdin> -> datetime --in "format" --out "format" -> <stdout>
    26  ```
    27  
    28  ## Examples
    29  
    30  Output current date and time:
    31  
    32  ```
    33  » datetime --in "{now}" --out "{go}01/02/06 15:04:05"
    34  12/08/21 22:32:30
    35  ```
    36  
    37  Convert STDIN into epoch:
    38  
    39  ```
    40  » echo "12/08/21 22:32:30" -> datetime --in "{go}01/02/06 15:04:05" --out "{unix}"
    41  1639002750
    42  ```
    43  
    44  Convert value passed as a command line argument:
    45  
    46  ```
    47  » datetime --value "12/08/21 22:32:30" --in "{go}01/02/06 15:04:05" --out "{unix}"
    48  1639002750
    49  ```
    50  
    51  ## Flags
    52  
    53  * `--in`
    54      Defines the date/time string is formatted in `--value`
    55  * `--out`
    56      Defined how the date/time string should be formatted in STDOUT
    57  * `--value`
    58      Date/time value to convert (if omitted and the input format is not set to `{now}` then date/time is read from STDIN)
    59  
    60  ## Detail
    61  
    62  ### Date Time Format Code Parsers
    63  
    64  `datetime` supports a number of parsers, defined in curly braces.
    65  
    66  #### `{py}`: Python strftime / strptime format codes
    67  
    68  Murex doesn't support all the language and locale features of Python, instead
    69  defaulting to English. However enough support is there to cover most use cases.
    70  
    71  Documentation regarding these format codes can be found on [docs.python.org](https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior).
    72  
    73  #### `{go}`: Go (lang) time.Time format codes
    74  
    75  Murex has full support for Go's date/time parsing.
    76  
    77  Documentation regarding these format codes can be found on [pkg.go.dev](https://pkg.go.dev/time#pkg-constants).
    78  
    79  #### `{now}`: Current date and time
    80  
    81  This is only supported as an input. When it is used `--value` flag is not
    82  required.
    83  
    84  ## See Also
    85  
    86  * [`[ ..Range ]`](../parser/range.md):
    87    Outputs a ranged subset of data from STDIN
    88  * [`a` (mkarray)](../commands/a.md):
    89    A sophisticated yet simple way to build an array or list
    90  
    91  <hr/>
    92  
    93  This document was generated from [builtins/core/typemgmt/datetime_doc.yaml](https://github.com/lmorg/murex/blob/master/builtins/core/typemgmt/datetime_doc.yaml).