Skip to content

Commit

Permalink
port examples/date_in_local_timezones.nu
Browse files Browse the repository at this point in the history
- embed the `core-team` table, remove `assets/core_team.nu`
- embed the `date local` function from `language/std/date`
- explicit print
- `str collect` -> `str join`
- `$block` -> `$closure`
- `date format` -> `format date`
  • Loading branch information
39555 committed May 25, 2024
1 parent ae3d743 commit 0927d2b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 27 deletions.
12 changes: 0 additions & 12 deletions before_v0.60/assets/core_team.nu

This file was deleted.

47 changes: 32 additions & 15 deletions modules/examples/date_in_local_timezones.nu
Original file line number Diff line number Diff line change
@@ -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)"})

0 comments on commit 0927d2b

Please sign in to comment.