zsh-users
 help / color / mirror / code / Atom feed
* Is there a way to get the “full” time zone currently in use?
@ 2018-07-27 16:12 TJ Luoma
  2018-07-27 23:09 ` Linus Arver
  0 siblings, 1 reply; 5+ messages in thread
From: TJ Luoma @ 2018-07-27 16:12 UTC (permalink / raw)
  To: Zsh-Users List

[-- Attachment #1: Type: text/plain, Size: 813 bytes --]

Hello Zsh Friends,

I am trying to use zsh to find the current time-zone that the computer uses.

I know that this:

`strftime "%Z" "$EPOCHSECONDS"`

will show me the current timezone (EDT, in my case) but I'm looking for
"America/New_York"

The only way that I can find to get that information on the Mac is

`sudo systemsetup -gettimezone`

but it seems absurd to need to use `sudo` to get that information.

I searched the web and found that the variable "TZ" is supposed to hold
this command, but TZ is empty in my testing on my Macs, so that's no help
either.

I've got to imagine that there's _some_ way to do this, but I'm stuck
trying to figure it out.

Anyone have a solution?

Thanks for your time

Tj


--
TJ Luoma
TJ @ MacStories
Personal Website: luo.ma (aka RhymesWithDiploma.com)
Twitter: @tjluoma

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Is there a way to get the “full” time zone currently in use?
  2018-07-27 16:12 Is there a way to get the “full” time zone currently in use? TJ Luoma
@ 2018-07-27 23:09 ` Linus Arver
  2018-07-29 12:56   ` TJ Luoma
  0 siblings, 1 reply; 5+ messages in thread
From: Linus Arver @ 2018-07-27 23:09 UTC (permalink / raw)
  To: luomat; +Cc: zsh-users

[-- Attachment #1: Type: text/plain, Size: 986 bytes --]

How about

    readlink /etc/localtime

?

On Fri, Jul 27, 2018 at 9:13 AM TJ Luoma <luomat@gmail.com> wrote:

> Hello Zsh Friends,
>
> I am trying to use zsh to find the current time-zone that the computer
> uses.
>
> I know that this:
>
> `strftime "%Z" "$EPOCHSECONDS"`
>
> will show me the current timezone (EDT, in my case) but I'm looking for
> "America/New_York"
>
> The only way that I can find to get that information on the Mac is
>
> `sudo systemsetup -gettimezone`
>
> but it seems absurd to need to use `sudo` to get that information.
>
> I searched the web and found that the variable "TZ" is supposed to hold
> this command, but TZ is empty in my testing on my Macs, so that's no help
> either.
>
> I've got to imagine that there's _some_ way to do this, but I'm stuck
> trying to figure it out.
>
> Anyone have a solution?
>
> Thanks for your time
>
> Tj
>
>
> --
> TJ Luoma
> TJ @ MacStories
> Personal Website: luo.ma (aka RhymesWithDiploma.com)
> Twitter: @tjluoma
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Is there a way to get the “full” time zone currently in use?
  2018-07-27 23:09 ` Linus Arver
@ 2018-07-29 12:56   ` TJ Luoma
  2018-07-29 15:32     ` Matthew Martin
  0 siblings, 1 reply; 5+ messages in thread
From: TJ Luoma @ 2018-07-29 12:56 UTC (permalink / raw)
  To: linusarver; +Cc: Zsh-Users List

[-- Attachment #1: Type: text/plain, Size: 1673 bytes --]

That works, and I haven’t found anything else that does. This:

readlink /etc/localtime | sed ’s#.*/zoneinfo/##g'

gives me the exact same information as

sudo systemsetup -gettimezone  | sed ’s#^Time Zone: ##g’

which is what I wanted.

Thanks!

TjL



--
TJ Luoma
TJ @ MacStories <http://www.macstories.net/author/tjluoma/>
Personal Website: luo.ma <http://luo.ma/> (aka RhymesWithDiploma.com
<http://rhymeswithdiploma.com/>)
Twitter: @tjluoma <http://twitter.com/tjluoma>



On Fri, Jul 27, 2018 at 7:09 PM Linus Arver <linusarver@gmail.com> wrote:

> How about
>
>     readlink /etc/localtime
>
> ?
>
> On Fri, Jul 27, 2018 at 9:13 AM TJ Luoma <luomat@gmail.com> wrote:
>
>> Hello Zsh Friends,
>>
>> I am trying to use zsh to find the current time-zone that the computer
>> uses.
>>
>> I know that this:
>>
>> `strftime "%Z" "$EPOCHSECONDS"`
>>
>> will show me the current timezone (EDT, in my case) but I'm looking for
>> "America/New_York"
>>
>> The only way that I can find to get that information on the Mac is
>>
>> `sudo systemsetup -gettimezone`
>>
>> but it seems absurd to need to use `sudo` to get that information.
>>
>> I searched the web and found that the variable "TZ" is supposed to hold
>> this command, but TZ is empty in my testing on my Macs, so that's no help
>> either.
>>
>> I've got to imagine that there's _some_ way to do this, but I'm stuck
>> trying to figure it out.
>>
>> Anyone have a solution?
>>
>> Thanks for your time
>>
>> Tj
>>
>>
>> --
>> TJ Luoma
>> TJ @ MacStories
>> Personal Website: luo.ma (aka RhymesWithDiploma.com)
>> Twitter: @tjluoma
>>
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Is there a way to get the “full” time zone currently in use?
  2018-07-29 12:56   ` TJ Luoma
@ 2018-07-29 15:32     ` Matthew Martin
  2018-07-31 13:54       ` TJ Luoma
  0 siblings, 1 reply; 5+ messages in thread
From: Matthew Martin @ 2018-07-29 15:32 UTC (permalink / raw)
  To: TJ Luoma; +Cc: linusarver, Zsh-Users List

On Sun, Jul 29, 2018 at 08:56:21AM -0400, TJ Luoma wrote:
> That works, and I haven’t found anything else that does. This:
> 
> readlink /etc/localtime | sed ’s#.*/zoneinfo/##g'

There's no need for external commands here.

a=(/etc/localtime(:A))  # Resolve the symlink
print ${a##*/zoneinfo/} # Remove text preceding and including /zoneinfo/

- Matthew Martin


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Is there a way to get the “full” time zone currently in use?
  2018-07-29 15:32     ` Matthew Martin
@ 2018-07-31 13:54       ` TJ Luoma
  0 siblings, 0 replies; 5+ messages in thread
From: TJ Luoma @ 2018-07-31 13:54 UTC (permalink / raw)
  To: Zsh-Users List

[-- Attachment #1: Type: text/plain, Size: 883 bytes --]

Wow. That’s excellent. Another Zsh feature that I clearly need to learn
more about, because I use ’sed’ for that sort of thing _all the time_.

Thanks!

TjL



--
TJ Luoma
TJ @ MacStories <http://www.macstories.net/author/tjluoma/>
Personal Website: luo.ma <http://luo.ma/> (aka RhymesWithDiploma.com
<http://rhymeswithdiploma.com/>)
Twitter: @tjluoma <http://twitter.com/tjluoma>



On Sun, Jul 29, 2018 at 11:32 AM Matthew Martin <phy1729@gmail.com> wrote:

> On Sun, Jul 29, 2018 at 08:56:21AM -0400, TJ Luoma wrote:
> > That works, and I haven’t found anything else that does. This:
> >
> > readlink /etc/localtime | sed ’s#.*/zoneinfo/##g'
>
> There's no need for external commands here.
>
> a=(/etc/localtime(:A))  # Resolve the symlink
> print ${a##*/zoneinfo/} # Remove text preceding and including /zoneinfo/
>
> - Matthew Martin
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-07-31 13:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-27 16:12 Is there a way to get the “full” time zone currently in use? TJ Luoma
2018-07-27 23:09 ` Linus Arver
2018-07-29 12:56   ` TJ Luoma
2018-07-29 15:32     ` Matthew Martin
2018-07-31 13:54       ` TJ Luoma

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).