Nushell
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
GitHub
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
GitHub
  • Categories

    • Bits
    • Bytes
    • Chart
    • Conversions
    • Core
    • Database
    • Dataframe
    • Dataframe Or Lazyframe
    • Date
    • Debug
    • Default
    • Env
    • Experimental
    • Expression
    • Filesystem
    • Filters
    • Formats
    • Generators
    • Hash
    • History
    • Lazyframe
    • Math
    • Misc
    • Network
    • Path
    • Platform
    • Plugin
    • Prompt
    • Random
    • Removed
    • Shells
    • Strings
    • System
    • Viewers

into duration for conversions

Convert value to duration.

Signature

> into duration {flags} ...rest

Flags

  • --unit, -u {string}: Unit to convert number into (will have an effect only with integer input)

Parameters

  • ...rest: For a data structure input, convert data at the given cell paths.

Input/output types:

inputoutput
intduration
floatduration
stringduration
durationduration
recordany
recordrecord
recordduration
tabletable

Examples

Convert duration string to duration value

> '7min' | into duration
7min

Convert compound duration string to duration value

> '1day 2hr 3min 4sec' | into duration
1day 2hr 3min 4sec

Convert table of duration strings to table of duration values

> [[value]; ['1sec'] ['2min'] ['3hr'] ['4day'] ['5wk']] | into duration value
╭───┬───────╮
│ # │ value │
├───┼───────┤
│ 0 │  1sec │
│ 1 │  2min │
│ 2 │   3hr │
│ 3 │  4day │
│ 4 │   5wk │
╰───┴───────╯

Convert duration to duration

> 420sec | into duration
7min

Convert a number of ns to duration

> 1_234_567 | into duration
1ms 234µs 567ns

Convert a number of an arbitrary unit to duration

> 1_234 | into duration --unit ms
1sec 234ms

Convert a floating point number of an arbitrary unit to duration

> 1.234 | into duration --unit sec
1sec 234ms

Convert a record to a duration

> {day: 10, hour: 2, minute: 6, second: 50, sign: '+'} | into duration
1wk 3day 2hr 6min 50sec

Notes

Max duration value is i64::MAX nanoseconds; max duration time unit is wk (weeks).