diff --git a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Simple.pm b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Simple.pm
index a462865a6..14b3ae313 100644
--- a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Simple.pm
+++ b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Simple.pm
@@ -1456,6 +1456,32 @@ sub stamp {
return $self->{cipher} ? $self->{cipher}->encrypt( time() ) : 1;
}
+## @method string convertSec(int sec)
+# Convert seconds to hours, minutes, seconds
+# @param $sec number of seconds
+# @return a formated time
+sub convertSec {
+ my ( $self, $sec ) = splice @_;
+
+ # If we only have seconds
+ return "00:00:$sec" if ( $sec < 60 );
+
+ # Calculate the minutes
+ my $min = $sec / 60, $sec %= 60;
+ $min = int($min);
+ return "00:$min:$sec" if ( $min < 60 );
+
+ # Calculate the hours
+ my $hrs = $min / 60, $min %= 60;
+ $hrs = int($hrs);
+ return "$hrs:$min:$sec" if ( $hrs < 24 );
+
+ # Calculate the days
+ my $days = $hrs / 24, $hrs %= 24;
+ $days = int($days);
+ return "$days:$hrs:$min:$sec" if ( $days < 365 );
+}
+
###############################################################
# MAIN subroutine: call all steps until one returns something #
# different than PE_OK #
diff --git a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/_LDAP.pm b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/_LDAP.pm
index fd9876a4e..da288a331 100644
--- a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/_LDAP.pm
+++ b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/_LDAP.pm
@@ -175,7 +175,7 @@ sub userBind {
}
if ( $resp->time_before_expiration ) {
$self->{portal}->info( "
"
- . $resp->time_before_expiration . " "
+ . $self->convertSec($resp->time_before_expiration) . " "
. $self->msg(PM_PP_EXP_WARNING)
. "
" );
}
diff --git a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/_i18n.pm b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/_i18n.pm
index 88c6a77fc..e91017a4c 100644
--- a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/_i18n.pm
+++ b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/_i18n.pm
@@ -163,7 +163,7 @@ sub error_fr {
'Mot de passe trop récent',
'Mot de passe utilisé trop récemment',
' authentifications restantes, changez votre mot de passe !',
-' secondes avant expiration de votre mot de passe, pensez à le changer !',
+ ' avant expiration de votre mot de passe, pensez à le changer !',
'Les mots de passe ne correspondent pas',
'Le mot de passe a été changé',
'Vous avez un nouveau message',
@@ -249,7 +249,7 @@ sub error_en {
'Password too young',
'Password used too recently',
' authentications remaining, change your password!',
- ' seconds before password expiration, change it!',
+ ' before password expiration, change it!',
'Passwords mismatch',
'Password successfully changed',
'You have a new message',
@@ -336,7 +336,7 @@ sub error_ro {
'Prea parolă nouă',
'Parola folosit prea recent',
' authentications rămase, schimbaţi-vă parola!',
-' secunde înainte de expirarea parola dvs., asiguraţi-vă pentru a schimba!',
+ ' înainte de expirarea parola dvs., asiguraţi-vă pentru a schimba!',
'Parolele nu se potrivesc',
'Parola a fost schimbată',
'Ai un mesaj nou',
diff --git a/lemonldap-ng-portal/t/01-Lemonldap-NG-Portal-Simple.t b/lemonldap-ng-portal/t/01-Lemonldap-NG-Portal-Simple.t
index b7cd3626c..03316d400 100644
--- a/lemonldap-ng-portal/t/01-Lemonldap-NG-Portal-Simple.t
+++ b/lemonldap-ng-portal/t/01-Lemonldap-NG-Portal-Simple.t
@@ -5,7 +5,7 @@
# change 'tests => 1' to 'tests => last_test_to_print';
-use Test::More tests => 10;
+use Test::More tests => 11;
BEGIN { use_ok( 'Lemonldap::NG::Portal::Simple', ':all' ) }
@@ -94,3 +94,6 @@ ok( $p->process > 0, 'User OK' );
# Cookie test
ok( $p->{cookie}->[0]->value eq '1', 'Cookie value' );
+# convertSec test
+ok($p->convertSec(650) eq '00:10:50', 'convertSec');
+