-
Notifications
You must be signed in to change notification settings - Fork 233
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
port
examples/date_in_local_timezones.nu
- 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
Showing
2 changed files
with
32 additions
and
27 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)"}) |