diff options
author | spalax <spalax@web> | 2016-12-25 17:05:08 -0400 |
---|---|---|
committer | admin <admin@branchable.com> | 2016-12-25 17:05:08 -0400 |
commit | 1a73c8d5284093de58b71cf26830c2aacf350b4f (patch) | |
tree | f7db70a743240c090774ac05c9db5ee551d42dae /doc | |
parent | 28409cd358d5ff17e2c340298988e8baf86fd5f5 (diff) | |
download | ikiwiki-1a73c8d5284093de58b71cf26830c2aacf350b4f.tar ikiwiki-1a73c8d5284093de58b71cf26830c2aacf350b4f.tar.gz |
Question about default timezone ":/etc/localtime"
Diffstat (limited to 'doc')
-rw-r--r-- | doc/forum/How_to_parse___34__:__47__etc__47__localtime__34___timezone__63__.mdwn | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/doc/forum/How_to_parse___34__:__47__etc__47__localtime__34___timezone__63__.mdwn b/doc/forum/How_to_parse___34__:__47__etc__47__localtime__34___timezone__63__.mdwn new file mode 100644 index 000000000..cf7f2b5fa --- /dev/null +++ b/doc/forum/How_to_parse___34__:__47__etc__47__localtime__34___timezone__63__.mdwn @@ -0,0 +1,13 @@ +Hello, +I am writing a plugin that uses the timezone. Ikiwiki.pm [defines the default timezone](http://source.ikiwiki.branchable.com/?p=source.git;a=blob;f=IkiWiki.pm;h=fa71f479107a2388fde2fe00a67bfa2daa4fb3a9;hb=HEAD#l638) to ``:/etc/localtime``. The problem is that I do not know how to parse this. + +In my code, I have lines like ``$now = DateTime->now(time_zone => $config{timezone});`` or ``$thistime = DateTime->from_epoch(epoch=>$thistime, time_zone=>$config{timezone});``. They work well when timezone is something like ``Europe/Paris``, but with the default ``:/etc/localtime``, I get the error message ``The timezone ':/etc/localtime' is an invalid name.`` + +Is there a way to automatically recognize both ``Europe/Paris`` and ``:/etc/localtime``? Or should I add something like the following in my code? + + if ($config{timezone} eq ":/etc/localtime") { + $config{timezone} = DateTime::TimeZone->new(name=>'local')->name(); + } + +Regards, +[[Louis|spalax]] |