2019-01-12 14:02:53 +00:00
# $Id: $
2019-01-09 09:37:55 +00:00
###############################################################################
#
# Developed with Kate
#
# (c) 2019 Copyright: Marko Oldenburg (leongaultier at gmail dot com)
# All rights reserved
#
# Special thanks goes to:
#
#
# This script is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License,or
# any later version.
#
# The GNU General Public License can be found at
# http://www.gnu.org/copyleft/gpl.html.
# A copy is found in the textfile GPL.txt and important notices to the license
# from the author is found in LICENSE.txt distributed with these scripts.
#
# This script is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
###############################################################################
### Beispielaufruf
# https://api.openweathermap.org/data/2.5/weather?lat=[lat]&lon=[long]&APPID=[API] Current
2019-01-09 23:11:19 +00:00
# https://api.openweathermap.org/data/2.5/forecast?lat=[lat]&lon=[long]&APPID=[API] Forecast
2019-01-09 09:37:55 +00:00
# https://openweathermap.org/weather-conditions Icons und Conditions ID's
2019-03-15 20:41:32 +00:00
package OpenWeatherMapAPI::Weather ;
2019-01-09 09:37:55 +00:00
use strict ;
use warnings ;
use POSIX ;
use HttpUtils ;
2019-06-15 07:42:07 +00:00
# try to use JSON::MaybeXS wrapper
# for chance of better performance + open code
eval {
require JSON::MaybeXS ;
import JSON:: MaybeXS qw( decode_json encode_json ) ;
1 ;
} ;
if ( $@ ) {
$@ = undef ;
# try to use JSON wrapper
# for chance of better performance
eval {
# JSON preference order
local $ ENV { PERL_JSON_BACKEND } =
'Cpanel::JSON::XS,JSON::XS,JSON::PP,JSON::backportPP'
unless ( defined ( $ ENV { PERL_JSON_BACKEND } ) ) ;
require JSON ;
import JSON qw( decode_json encode_json ) ;
1 ;
} ;
if ( $@ ) {
$@ = undef ;
# In rare cases, Cpanel::JSON::XS may
# be installed but JSON|JSON::MaybeXS not ...
eval {
require Cpanel::JSON::XS ;
import Cpanel::JSON:: XS qw( decode_json encode_json ) ;
1 ;
} ;
if ( $@ ) {
$@ = undef ;
# In rare cases, JSON::XS may
# be installed but JSON not ...
eval {
require JSON::XS ;
import JSON:: XS qw( decode_json encode_json ) ;
1 ;
} ;
if ( $@ ) {
$@ = undef ;
# Fallback to built-in JSON which SHOULD
# be available since 5.014 ...
eval {
require JSON::PP ;
import JSON:: PP qw( decode_json encode_json ) ;
1 ;
} ;
if ( $@ ) {
$@ = undef ;
# Fallback to JSON::backportPP in really rare cases
require JSON::backportPP ;
import JSON:: backportPP qw( decode_json encode_json ) ;
1 ;
}
}
}
}
}
2019-01-09 09:37:55 +00:00
my $ missingModul = '' ;
eval "use Encode qw(encode_utf8);1" or $ missingModul . = "Encode " ;
2019-01-12 15:20:31 +00:00
# use Data::Dumper; # for Debug only
2019-01-09 09:37:55 +00:00
## API URL
2019-06-15 07:36:11 +00:00
use constant URL = > 'https://api.openweathermap.org/data/2.5/' ;
2019-06-15 07:42:07 +00:00
use constant VERSION = > '0.4.0' ;
2019-01-09 09:37:55 +00:00
## URL . 'weather?' for current data
2019-01-09 23:11:19 +00:00
## URL . 'forecast?' for forecast data
2019-01-09 09:37:55 +00:00
my % codes = (
2019-01-09 11:17:10 +00:00
200 = > 45 ,
201 = > 45 ,
202 = > 45 ,
210 = > 4 ,
211 = > 4 ,
212 = > 3 ,
221 = > 4 ,
230 = > 45 ,
231 = > 45 ,
232 = > 45 ,
300 = > 9 ,
301 = > 9 ,
302 = > 9 ,
310 = > 9 ,
311 = > 9 ,
312 = > 9 ,
313 = > 9 ,
314 = > 9 ,
321 = > 9 ,
500 = > 35 ,
501 = > 35 ,
502 = > 35 ,
503 = > 35 ,
504 = > 35 ,
511 = > 35 ,
520 = > 35 ,
521 = > 35 ,
522 = > 35 ,
531 = > 35 ,
2019-01-09 12:14:06 +00:00
600 = > 14 ,
601 = > 16 ,
602 = > 13 ,
611 = > 46 ,
612 = > 46 ,
2019-01-09 12:42:27 +00:00
615 = > 5 ,
616 = > 5 ,
620 = > 14 ,
621 = > 46 ,
622 = > 42 ,
701 = > 19 ,
711 = > 22 ,
721 = > 19 ,
731 = > 23 ,
741 = > 20 ,
751 = > 23 ,
761 = > 19 ,
762 = > 3200 ,
771 = > 1 ,
781 = > 0 ,
800 = > 32 ,
801 = > 30 ,
802 = > 26 ,
803 = > 26 ,
804 = > 28 ,
2019-01-09 09:37:55 +00:00
) ;
sub new {
### geliefert wird ein Hash
my ( $ class , $ argsRef ) = @ _ ;
2019-06-15 07:36:11 +00:00
my $ apioptions = parseApiOptions ( $ argsRef - > { apioptions } ) ;
2019-01-09 09:37:55 +00:00
my $ self = {
2019-01-10 21:35:57 +00:00
devName = > $ argsRef - > { devName } ,
key = > (
( defined ( $ argsRef - > { apikey } ) and $ argsRef - > { apikey } )
? $ argsRef - > { apikey }
: 'none'
) ,
lang = > $ argsRef - > { language } ,
lat = > ( split ( ',' , $ argsRef - > { location } ) ) [ 0 ] ,
long = > ( split ( ',' , $ argsRef - > { location } ) ) [ 1 ] ,
fetchTime = > 0 ,
endpoint = > 'none' ,
2019-01-09 09:37:55 +00:00
} ;
2019-01-09 11:17:10 +00:00
2019-06-15 07:36:11 +00:00
$ self - > { cachemaxage } = (
defined ( $ apioptions - > { cachemaxage } )
? $ apioptions - > { cachemaxage }
: 900 ) ;
2019-01-09 23:11:19 +00:00
$ self - > { cached } = _CreateForecastRef ( $ self ) ;
2019-01-09 09:37:55 +00:00
bless $ self , $ class ;
return $ self ;
}
2019-03-19 20:35:59 +00:00
sub parseApiOptions ($) {
my $ apioptions = shift ;
my @ params ;
my % h ;
2019-06-15 07:36:11 +00:00
@ params = split ( ',' , $ apioptions ) ;
2019-03-19 20:35:59 +00:00
while ( @ params ) {
my $ param = shift ( @ params ) ;
2019-06-15 07:36:11 +00:00
next if ( $ param eq '' ) ;
my ( $ key , $ value ) = split ( ':' , $ param , 2 ) ;
2019-03-19 20:35:59 +00:00
$ h { $ key } = $ value ;
}
2019-06-15 07:36:11 +00:00
2019-03-19 20:35:59 +00:00
return \ % h ;
}
2019-01-09 09:37:55 +00:00
sub setFetchTime {
my $ self = shift ;
$ self - > { fetchTime } = time ( ) ;
return 0 ;
}
sub setRetrieveData {
my $ self = shift ;
_RetrieveDataFromOpenWeatherMap ( $ self ) ;
return 0 ;
}
sub getFetchTime {
my $ self = shift ;
return $ self - > { fetchTime } ;
}
sub getWeather {
my $ self = shift ;
return $ self - > { cached } ;
}
sub _RetrieveDataFromOpenWeatherMap ($) {
my $ self = shift ;
# retrieve data from cache
2019-01-10 21:35:57 +00:00
if ( $ self - > { endpoint } eq 'none' ) {
if ( ( time ( ) - $ self - > { fetchTime } ) < $ self - > { cachemaxage } ) {
2019-01-09 23:11:19 +00:00
return _CallWeatherCallbackFn ( $ self ) ;
}
2019-01-09 09:37:55 +00:00
}
my $ paramRef = {
timeout = > 15 ,
self = > $ self ,
2019-01-09 23:11:19 +00:00
endpoint = > ( $ self - > { endpoint } eq 'none' ? 'weather' : 'forecast' ) ,
2019-01-09 09:37:55 +00:00
callback = > \ & _RetrieveDataFinished ,
} ;
$ self - > { endpoint } = $ paramRef - > { endpoint } ;
if ( $ self - > { lat } eq 'error'
or $ self - > { long } eq 'error'
or $ self - > { key } eq 'none'
or $ missingModul )
{
2019-01-09 11:17:10 +00:00
_RetrieveDataFinished (
$ paramRef ,
'The given location is invalid. (wrong latitude or longitude?) put both as an attribute in the global device or set define option location=[LAT],[LONG]' ,
undef
) if ( $ self - > { lat } eq 'error' or $ self - > { long } eq 'error' ) ;
2019-01-09 09:37:55 +00:00
_RetrieveDataFinished ( $ paramRef ,
2019-01-09 11:17:10 +00:00
'No given api key. (define myWeather Weather apikey=[KEY])' ,
2019-01-09 09:37:55 +00:00
undef )
if ( $ self - > { key } eq 'none' ) ;
_RetrieveDataFinished ( $ paramRef ,
'Perl modul ' . $ missingModul . ' is missing.' , undef )
if ( $ missingModul ) ;
}
else {
$ paramRef - > { url } =
URL
2019-01-09 11:17:10 +00:00
. $ paramRef - > { endpoint } . '?' . 'lat='
. $ self - > { lat } . '&' . 'lon='
2019-01-09 09:37:55 +00:00
. $ self - > { long } . '&'
. 'APPID='
2019-01-09 11:17:10 +00:00
. $ self - > { key } . '&' . 'lang='
2019-01-09 09:37:55 +00:00
. $ self - > { lang } ;
main:: HttpUtils_NonblockingGet ( $ paramRef ) ;
}
}
sub _RetrieveDataFinished ($$$) {
my ( $ paramRef , $ err , $ response ) = @ _ ;
my $ self = $ paramRef - > { self } ;
if ( ! $ err ) {
2019-01-09 11:17:10 +00:00
$ self - > { cached } - > { status } = 'ok' ;
$ self - > { cached } - > { validity } = 'up-to-date' , $ self - > { fetchTime } = time ( ) ;
2019-01-09 09:37:55 +00:00
_ProcessingRetrieveData ( $ self , $ response ) ;
}
else {
$ self - > { fetchTime } = time ( ) if ( not defined ( $ self - > { fetchTime } ) ) ;
_ErrorHandling ( $ self , $ err ) ;
_ProcessingRetrieveData ( $ self , $ response ) ;
}
}
sub _ProcessingRetrieveData ($$) {
my ( $ self , $ response ) = @ _ ;
2019-01-10 21:35:57 +00:00
if ( $ self - > { cached } - > { status } eq 'ok'
and defined ( $ response )
and $ response )
{
2019-01-13 08:22:28 +00:00
if ( $ response =~ m/^{.*}$/ ) {
my $ data = eval { decode_json ( $ response ) } ;
2019-01-09 11:17:10 +00:00
2019-01-13 08:22:28 +00:00
if ( $@ ) {
_ErrorHandling ( $ self ,
'OpenWeatherMap Weather decode JSON err ' . $@ ) ;
2019-01-09 23:11:19 +00:00
}
2019-01-13 08:22:28 +00:00
elsif ( defined ( $ data - > { cod } )
and $ data - > { cod }
and $ data - > { cod } != 200
and defined ( $ data - > { message } )
and $ data - > { message } )
{
_ErrorHandling ( $ self , $ data - > { cod } . ': ' . $ data - > { message } ) ;
}
else {
2019-01-15 13:51:50 +00:00
### Debug
2019-06-15 07:36:11 +00:00
# print 'Response: ' . Dumper $data;
2019-01-13 08:22:28 +00:00
###### Ab hier wird die ResponseHash Referenze für die Rückgabe zusammen gestellt
$ self - > { cached } - > { current_date_time } =
2019-06-15 07:36:11 +00:00
strftimeWrapper ( "%a, %e %b %Y %H:%M" ,
2019-03-14 17:40:42 +00:00
localtime ( $ self - > { fetchTime } ) ) ;
2019-01-13 08:22:28 +00:00
if ( $ self - > { endpoint } eq 'weather' ) {
2019-06-15 07:36:11 +00:00
$ self - > { cached } - > { country } = $ data - > { sys } - > { country } ;
$ self - > { cached } - > { city } = encode_utf8 ( $ data - > { name } ) ;
2019-01-13 08:22:28 +00:00
$ self - > { cached } - > { license } { text } = 'none' ;
2019-06-15 07:36:11 +00:00
$ self - > { cached } - > { current } = {
2019-01-13 08:22:28 +00:00
'temperature' = > int (
2019-06-15 07:36:11 +00:00
sprintf ( "%.1f" ,
( $ data - > { main } - > { temp } - 273.15 ) ) + 0.5
2019-01-13 08:22:28 +00:00
) ,
'temp_c' = > int (
2019-06-15 07:36:11 +00:00
sprintf ( "%.1f" ,
( $ data - > { main } - > { temp } - 273.15 ) ) + 0.5
2019-01-13 08:22:28 +00:00
) ,
'low_c' = > int (
sprintf ( "%.1f" ,
( $ data - > { main } - > { temp_min } - 273.15 ) ) + 0.5
) ,
'high_c' = > int (
sprintf ( "%.1f" ,
( $ data - > { main } - > { temp_max } - 273.15 ) ) + 0.5
) ,
'tempLow' = > int (
sprintf ( "%.1f" ,
( $ data - > { main } - > { temp_min } - 273.15 ) ) + 0.5
) ,
'tempHigh' = > int (
sprintf ( "%.1f" ,
( $ data - > { main } - > { temp_max } - 273.15 ) ) + 0.5
) ,
'humidity' = > $ data - > { main } - > { humidity } ,
'condition' = >
2019-06-15 07:36:11 +00:00
encode_utf8 ( $ data - > { weather } - > [ 0 ] - > { description } ) ,
'pressure' = > int (
sprintf ( "%.1f" , $ data - > { main } - > { pressure } ) + 0.5
) ,
'wind' = > int (
sprintf ( "%.1f" , ( $ data - > { wind } - > { speed } * 3.6 ) )
+ 0.5
) ,
'wind_speed' = > int (
sprintf ( "%.1f" , ( $ data - > { wind } - > { speed } * 3.6 ) )
+ 0.5
) ,
2019-01-13 08:22:28 +00:00
'wind_direction' = > $ data - > { wind } - > { deg } ,
'cloudCover' = > $ data - > { clouds } - > { all } ,
'visibility' = >
2019-06-15 07:36:11 +00:00
int ( sprintf ( "%.1f" , $ data - > { visibility } ) + 0.5 ) ,
2019-01-13 08:22:28 +00:00
'code' = > $ codes { $ data - > { weather } - > [ 0 ] - > { id } } ,
'iconAPI' = > $ data - > { weather } - > [ 0 ] - > { icon } ,
2019-03-14 17:40:42 +00:00
'sunsetTime' = > strftimeWrapper (
2019-01-14 17:16:39 +00:00
"%a, %e %b %Y %H:%M" ,
2019-01-13 08:22:28 +00:00
localtime ( $ data - > { sys } - > { sunset } )
2019-03-14 17:40:42 +00:00
) ,
'sunriseTime' = > strftimeWrapper (
2019-01-14 17:16:39 +00:00
"%a, %e %b %Y %H:%M" ,
2019-01-13 08:22:28 +00:00
localtime ( $ data - > { sys } - > { sunrise } )
2019-03-14 17:40:42 +00:00
) ,
'pubDate' = > strftimeWrapper (
2019-01-14 17:16:39 +00:00
"%a, %e %b %Y %H:%M" ,
2019-01-13 08:22:28 +00:00
localtime ( $ data - > { dt } )
2019-03-14 17:40:42 +00:00
) ,
2019-01-13 08:22:28 +00:00
} ;
}
2019-01-09 23:11:19 +00:00
2019-01-13 08:22:28 +00:00
if ( $ self - > { endpoint } eq 'forecast' ) {
if ( ref ( $ data - > { list } ) eq "ARRAY"
and scalar ( @ { $ data - > { list } } ) > 0 )
{
## löschen des alten Datensatzes
delete $ self - > { cached } - > { forecast } ;
my $ i = 0 ;
foreach ( @ { $ data - > { list } } ) {
push (
@ { $ self - > { cached } - > { forecast } - > { hourly } } ,
{
2019-03-14 17:40:42 +00:00
'pubDate' = > strftimeWrapper (
2019-01-14 17:16:39 +00:00
"%a, %e %b %Y %H:%M" ,
2019-01-13 08:22:28 +00:00
localtime (
( $ data - > { list } - > [ $ i ] - > { dt } ) - 3600
2019-01-10 21:35:57 +00:00
)
2019-03-14 17:40:42 +00:00
) ,
2019-01-13 08:22:28 +00:00
'day_of_week' = > strftime (
2019-01-14 17:16:39 +00:00
"%a, %H:%M" ,
2019-01-13 08:22:28 +00:00
localtime (
( $ data - > { list } - > [ $ i ] - > { dt } ) - 3600
2019-01-10 21:35:57 +00:00
)
2019-01-13 08:22:28 +00:00
) ,
'temperature' = > int (
sprintf (
"%.1f" ,
(
2019-06-15 07:36:11 +00:00
$ data - > { list } - > [ $ i ] - > { main }
- > { temp } - 273.15
2019-01-13 08:22:28 +00:00
)
) + 0.5
) ,
'temp_c' = > int (
sprintf (
"%.1f" ,
(
2019-06-15 07:36:11 +00:00
$ data - > { list } - > [ $ i ] - > { main }
- > { temp } - 273.15
2019-01-13 08:22:28 +00:00
)
) + 0.5
) ,
'low_c' = > int (
sprintf (
"%.1f" ,
(
$ data - > { list } - > [ $ i ] - > { main }
2019-06-15 07:36:11 +00:00
- > { temp_min } - 273.15
2019-01-13 08:22:28 +00:00
)
) + 0.5
) ,
'high_c' = > int (
sprintf (
"%.1f" ,
(
$ data - > { list } - > [ $ i ] - > { main }
2019-06-15 07:36:11 +00:00
- > { temp_max } - 273.15
2019-01-13 08:22:28 +00:00
)
) + 0.5
) ,
'tempLow' = > int (
sprintf (
"%.1f" ,
(
$ data - > { list } - > [ $ i ] - > { main }
2019-06-15 07:36:11 +00:00
- > { temp_min } - 273.15
2019-01-13 08:22:28 +00:00
)
) + 0.5
) ,
'tempHigh' = > int (
sprintf (
"%.1f" ,
(
$ data - > { list } - > [ $ i ] - > { main }
2019-06-15 07:36:11 +00:00
- > { temp_max } - 273.15
2019-01-13 08:22:28 +00:00
)
) + 0.5
) ,
'humidity' = >
2019-06-15 07:36:11 +00:00
$ data - > { list } - > [ $ i ] - > { main } - > { humidity } ,
2019-01-13 08:22:28 +00:00
'condition' = > encode_utf8 (
$ data - > { list } - > [ $ i ] - > { weather } - > [ 0 ]
2019-06-15 07:36:11 +00:00
- > { description }
2019-01-13 08:22:28 +00:00
) ,
'pressure' = > int (
sprintf ( "%.1f" ,
2019-06-15 07:36:11 +00:00
$ data - > { list } - > [ $ i ] - > { main }
- > { pressure } ) + 0.5
2019-01-13 08:22:28 +00:00
) ,
'wind' = > int (
2019-06-15 07:36:11 +00:00
sprintf (
"%.1f" ,
(
$ data - > { list } - > [ $ i ] - > { wind }
- > { speed } * 3.6
)
) + 0.5
2019-01-13 08:22:28 +00:00
) ,
'wind_speed' = > int (
2019-06-15 07:36:11 +00:00
sprintf (
"%.1f" ,
(
$ data - > { list } - > [ $ i ] - > { wind }
- > { speed } * 3.6
)
) + 0.5
2019-01-13 08:22:28 +00:00
) ,
'cloudCover' = >
2019-06-15 07:36:11 +00:00
$ data - > { list } - > [ $ i ] - > { clouds } - > { all } ,
'code' = > $ codes {
$ data - > { list } - > [ $ i ] - > { weather } - > [ 0 ]
- > { id }
} ,
2019-01-13 08:22:28 +00:00
'iconAPI' = >
2019-06-15 07:36:11 +00:00
$ data - > { list } - > [ $ i ] - > { weather } - > [ 0 ]
- > { icon } ,
2019-01-15 13:51:50 +00:00
'rain1h' = >
2019-06-15 07:36:11 +00:00
$ data - > { list } - > [ $ i ] - > { rain } - > { '1h' } ,
2019-01-15 13:51:50 +00:00
'rain3h' = >
2019-06-15 07:36:11 +00:00
$ data - > { list } - > [ $ i ] - > { rain } - > { '3h' } ,
2019-01-15 13:51:50 +00:00
'snow1h' = >
2019-06-15 07:36:11 +00:00
$ data - > { list } - > [ $ i ] - > { snow } - > { '1h' } ,
2019-01-15 13:51:50 +00:00
'snow3h' = >
2019-06-15 07:36:11 +00:00
$ data - > { list } - > [ $ i ] - > { snow } - > { '3h' } ,
2019-01-13 08:22:28 +00:00
} ,
) ;
$ i + + ;
}
2019-01-09 23:11:19 +00:00
}
}
}
2019-01-09 11:17:10 +00:00
}
2019-01-13 08:22:28 +00:00
else { _ErrorHandling ( $ self , 'OpenWeatherMap ' . $ response ) ; }
2019-01-09 11:17:10 +00:00
}
2019-01-10 21:35:57 +00:00
2019-01-09 23:11:19 +00:00
$ self - > { endpoint } = 'none' if ( $ self - > { endpoint } eq 'forecast' ) ;
2019-01-09 09:37:55 +00:00
2019-01-09 11:17:10 +00:00
_RetrieveDataFromOpenWeatherMap ( $ self )
if ( $ self - > { endpoint } eq 'weather' ) ;
2019-01-09 23:11:19 +00:00
_CallWeatherCallbackFn ( $ self ) if ( $ self - > { endpoint } eq 'none' ) ;
2019-01-09 09:37:55 +00:00
}
sub _CallWeatherCallbackFn ($) {
my $ self = shift ;
2019-01-10 21:35:57 +00:00
# print 'Dumperausgabe: ' . Dumper $self;
2019-01-09 23:11:19 +00:00
### Aufruf der callbackFn
2019-01-09 11:55:21 +00:00
main:: Weather_RetrieveCallbackFn ( $ self - > { devName } ) ;
2019-01-09 09:37:55 +00:00
}
sub _ErrorHandling ($$) {
2019-01-09 11:17:10 +00:00
my ( $ self , $ err ) = @ _ ;
2019-01-09 09:37:55 +00:00
2019-01-09 11:17:10 +00:00
$ self - > { cached } - > { current_date_time } =
2019-03-14 17:40:42 +00:00
strftimeWrapper ( "%a, %e %b %Y %H:%M" , localtime ( $ self - > { fetchTime } ) ) ,
2019-01-10 21:35:57 +00:00
$ self - > { cached } - > { status } = $ err ;
2019-01-09 09:37:55 +00:00
$ self - > { cached } - > { validity } = 'stale' ;
}
2019-01-09 23:11:19 +00:00
sub _CreateForecastRef ($) {
2019-01-09 09:37:55 +00:00
my $ self = shift ;
2019-01-09 23:11:19 +00:00
my $ forecastRef = (
2019-01-09 11:17:10 +00:00
{
lat = > $ self - > { lat } ,
long = > $ self - > { long } ,
apiMaintainer = >
'Leon Gaultier (<a href=https://forum.fhem.de/index.php?action=profile;u=13684>CoolTux</a>)' ,
2019-01-17 21:22:44 +00:00
apiVersion = > VERSION ,
2019-01-09 11:17:10 +00:00
}
) ;
2019-01-09 09:37:55 +00:00
2019-01-09 23:11:19 +00:00
return $ forecastRef ;
2019-01-09 09:37:55 +00:00
}
2019-03-14 17:40:42 +00:00
sub strftimeWrapper (@) {
my $ string = POSIX:: strftime ( @ _ ) ;
$ string =~ s/\xe4/ä/g ;
$ string =~ s/\xc4/Ä/g ;
$ string =~ s/\xf6/ö/g ;
$ string =~ s/\xd6/Ö/g ;
$ string =~ s/\xfc/ü/g ;
$ string =~ s/\xdc/Ü/g ;
$ string =~ s/\xdf/ß/g ;
$ string =~ s/\xdf/ß/g ;
$ string =~ s/\xe1/á/g ;
$ string =~ s/\xe9/é/g ;
$ string =~ s/\xc1/Á/g ;
$ string =~ s/\xc9/É/g ;
return $ string ;
}
2019-01-09 09:37:55 +00:00
##############################################################################
1 ;