diff --git a/before_v0.60/assets/core_team.nu b/before_v0.60/assets/core_team.nu deleted file mode 100644 index ed623d9b6..000000000 --- a/before_v0.60/assets/core_team.nu +++ /dev/null @@ -1,12 +0,0 @@ -def "nu core-team" [] { - [ - [ 'name', 'tz']; - [ 'andres', 'America/Guayaquil'] - [ 'fdncred', 'US/Central'] - [ 'gedge', 'US/Eastern'] - [ 'jt', 'NZ'] - [ 'wycats', 'US/Pacific'] - [ 'kubouch', 'Europe/Helsinki'] - ['elferherrera', 'Europe/London'] - ] -} diff --git a/modules/examples/date_in_local_timezones.nu b/modules/examples/date_in_local_timezones.nu index 2b8eb2c59..40518e299 100644 --- a/modules/examples/date_in_local_timezones.nu +++ b/modules/examples/date_in_local_timezones.nu @@ -1,25 +1,42 @@ -source lib/scripts.nu -source assets/core_team.nu -let next_call = ("2021-08-31 15:00:21.290597200 -05:00" | str to-datetime); +def "nu core-team" [] { + [ + [ 'name', 'tz']; + [ 'andres', 'America/Guayaquil'] + [ 'fdncred', 'US/Central'] + [ 'gedge', 'US/Eastern'] + [ 'jt', 'NZ'] + [ 'wycats', 'US/Pacific'] + [ 'kubouch', 'Europe/Helsinki'] + ['elferherrera', 'Europe/London'] + ] +} + +def "date local" [now] { + insert time {|value| + let converted = ($now | date to-timezone $value.tz); + + $converted | format date '%c' + } +} + +let next_call = ("2021-08-31 15:00:21.290597200 -05:00" | into datetime); let people = (nu core-team | date local $next_call); -def say [block] { - each {|person| - do $block ( - $person | merge { - [[name]; [($person.name | str capitalize)]] - } +def say [closure] { + $in | each {|person| + do $closure ( + $person | update name {|row| $row.name | str capitalize} ) - } | str collect (char newline) + } | str join (char newline) } -$people | say {|person| $"($person.name)'s timezone is ($person.tz)"} +print ($people | say {|person| $"($person.name)'s timezone is ($person.tz)"}) -$" +print ($" -for the next call happening on ($next_call | date format '%c').. in their timezones they would be: +for the next call happening on ($next_call | format date '%c').. in their timezones they would be: -" +") -$people | say {|person| $"($person.name)'s: ($person.time)"} +print ($people | say {|person| $"($person.name)'s: ($person.time)"})