In the past, you need modify rtc_api.c in mbed-dev source code. From this revision, you can just use RTC function all of conditions (Normal, Reset, Stand-by, Power OFF).

Note

From now on, you do NOT need any modification for mbed-dev library because STM team updates rtc_api.c source code and support RTC function under reset & standby condition includes power off condition (You need additional VBAT back-up hardware).

Please refer following NOTE information.
/users/kenjiArai/notebook/nucleo-series-rtc-control-under-power-onoff-and-re/

Revision:
2:77ec44bf1fa5
Parent:
1:7a48c475bbd2
Child:
3:7b3edf54c706
--- a/main.cpp	Sat Feb 14 11:35:34 2015 +0000
+++ b/main.cpp	Mon Feb 16 13:07:57 2015 +0000
@@ -6,7 +6,7 @@
  *  http://www.page.sannet.ne.jp/kenjia/index.html
  *  http://mbed.org/users/kenjiArai/
  *      Created: January   17th, 2015
- *      Revised: Feburary  14th, 2015
+ *      Revised: Feburary  16th, 2015
  *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
@@ -18,7 +18,7 @@
 //  Include ---------------------------------------------------------------------------------------
 #include "mbed.h"
 #include "TextLCD.h"
- // MUST -> need to modify rtc_api.c, please refer SetRTC.h file [CATION] and modify_info_xxx.h
+ // MUST -> need to modify rtc_api.c, please refer SetRTC.h file [CAUTION] and modify_info_xxx.h
 #include "SetRTC.h"
 
 //  Definition ------------------------------------------------------------------------------------
@@ -66,20 +66,20 @@
     lcd.setContrast(0x14);
 #endif
     pc.printf("\r\n\r\nTest Nucleo RTC Function\r\n");
+    myled = !myled;
+    if (SetRTC() == OK) {
+        pc.printf("External");
+    } else {
+        pc.printf("Internal");
+    }
+    pc.printf(" Xtal for RTC\r\n");
+    show_RTC_reg(); // only for debug purpose
     // waiting for Initial screen
     myled = 1;
     wait(1.0);
     myled = !myled;
     wait(1.0);
-    myled = !myled;
-    if (SetRTC() == OK) {
-        pc.printf("External Xtal for RTC\r\n");
-    } else {
-        pc.printf("Internal Xtal for RTC\r\n");
-    }
-    show_RTC_reg(); // only for debug purpose
     while(1) {
-        myled = 1;
         seconds = time(NULL);
         strftime(buf, 40, " %B %d,'%y, %H:%M:%S\r\n", localtime(&seconds));
         pc.printf("[Time] %s", buf);
@@ -91,34 +91,35 @@
         strftime(buf, 10, "%H:%M:%S", localtime(&seconds));
         lcd.printf(buf);
 #endif
+        --counter;
         if (counter){
-            --counter;
             //      012345678901234567890123456789012345678901234567890123456789012
             pc.printf("Is time correct? If no, hit any key.\r");
-            wait(1.0);
+        }
+        while (seconds == time(NULL)){
             if (pc.readable() == 1){
                 buf[0] = pc.getc();  // dummy read
                 time_enter_mode();
-                counter = SHOW_KEY_PROMPT;
             }
-            pc.printf("                                                                 \r");
-        } else {
-            wait(1.0);
-        }
-        if (userSW == 0){
+            if (userSW == 0){
 #if defined(USE_LCD)
-            lcd.locate(0, 0);    // 1st line top
-            //          12345678
-            lcd.printf(" Enter  ");
-            lcd.locate(0, 1);    // 2nd line top
-            //          12345678
-            lcd.printf("  Sleep " );
+                lcd.locate(0, 0);    // 1st line top
+                //          12345678
+                lcd.printf(" Enter  ");
+                lcd.locate(0, 1);    // 2nd line top
+                //          12345678
+                lcd.printf("  Sleep " );
 #endif
-            pc.printf("\r\nEnter Deep Sleep Mode, please push RESET to wake-up\r\n");
-            wait(1.0);
-            myled = 0;
-            deepsleep_preparation();      
-            deepsleep();
+                pc.printf("\r\nEnter Deep Sleep Mode, please push RESET to wake-up\r\n");
+                wait(1.0);
+                myled = 0;
+                deepsleep_preparation();      
+                deepsleep();
+            }
         }
+        if (counter){
+            pc.printf("                                                                 \r");
+        }
+        myled = !myled;
     }
 }