The official mbed C/C SDK provides the software platform and libraries to build your applications.

Fork of mbed by mbed official

Committer:
ldyz
Date:
Fri Jul 05 13:16:13 2013 +0000
Revision:
64:75c1708b266b
Parent:
59:0883845fe643
test

Who changed what in which revision?

UserRevisionLine numberNew contents of line
emilmont 44:24d45a770a51 1 /* mbed Microcontroller Library
emilmont 54:71b101360fb9 2 * Copyright (c) 2006-2013 ARM Limited
emilmont 44:24d45a770a51 3 *
emilmont 59:0883845fe643 4 * Licensed under the Apache License, Version 2.0 (the "License");
emilmont 59:0883845fe643 5 * you may not use this file except in compliance with the License.
emilmont 59:0883845fe643 6 * You may obtain a copy of the License at
emilmont 59:0883845fe643 7 *
emilmont 59:0883845fe643 8 * http://www.apache.org/licenses/LICENSE-2.0
emilmont 44:24d45a770a51 9 *
emilmont 59:0883845fe643 10 * Unless required by applicable law or agreed to in writing, software
emilmont 59:0883845fe643 11 * distributed under the License is distributed on an "AS IS" BASIS,
emilmont 59:0883845fe643 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
emilmont 59:0883845fe643 13 * See the License for the specific language governing permissions and
emilmont 59:0883845fe643 14 * limitations under the License.
emilmont 44:24d45a770a51 15 */
emilmont 44:24d45a770a51 16
emilmont 44:24d45a770a51 17 #include <time.h>
emilmont 44:24d45a770a51 18
emilmont 44:24d45a770a51 19 #ifdef __cplusplus
emilmont 44:24d45a770a51 20 extern "C" {
emilmont 44:24d45a770a51 21 #endif
emilmont 44:24d45a770a51 22
emilmont 44:24d45a770a51 23 /** Implementation of the C time.h functions
emilmont 44:24d45a770a51 24 *
emilmont 44:24d45a770a51 25 * Provides mechanisms to set and read the current time, based
emilmont 55:d722ed6a4237 26 * on the microcontroller Real-Time Clock (RTC), plus some
emilmont 55:d722ed6a4237 27 * standard C manipulation and formating functions.
emilmont 44:24d45a770a51 28 *
emilmont 44:24d45a770a51 29 * Example:
emilmont 44:24d45a770a51 30 * @code
emilmont 44:24d45a770a51 31 * #include "mbed.h"
emilmont 44:24d45a770a51 32 *
emilmont 44:24d45a770a51 33 * int main() {
emilmont 44:24d45a770a51 34 * set_time(1256729737); // Set RTC time to Wed, 28 Oct 2009 11:35:37
emilmont 55:d722ed6a4237 35 *
emilmont 55:d722ed6a4237 36 * while(1) {
emilmont 44:24d45a770a51 37 * time_t seconds = time(NULL);
emilmont 55:d722ed6a4237 38 *
emilmont 44:24d45a770a51 39 * printf("Time as seconds since January 1, 1970 = %d\n", seconds);
emilmont 55:d722ed6a4237 40 *
emilmont 44:24d45a770a51 41 * printf("Time as a basic string = %s", ctime(&seconds));
emilmont 44:24d45a770a51 42 *
emilmont 44:24d45a770a51 43 * char buffer[32];
emilmont 44:24d45a770a51 44 * strftime(buffer, 32, "%I:%M %p\n", localtime(&seconds));
emilmont 44:24d45a770a51 45 * printf("Time as a custom formatted string = %s", buffer);
emilmont 55:d722ed6a4237 46 *
emilmont 44:24d45a770a51 47 * wait(1);
emilmont 44:24d45a770a51 48 * }
emilmont 44:24d45a770a51 49 * }
emilmont 44:24d45a770a51 50 * @endcode
emilmont 44:24d45a770a51 51 */
emilmont 44:24d45a770a51 52
emilmont 44:24d45a770a51 53 /** Set the current time
emilmont 44:24d45a770a51 54 *
emilmont 44:24d45a770a51 55 * Initialises and sets the time of the microcontroller Real-Time Clock (RTC)
emilmont 55:d722ed6a4237 56 * to the time represented by the number of seconds since January 1, 1970
emilmont 55:d722ed6a4237 57 * (the UNIX timestamp).
emilmont 55:d722ed6a4237 58 *
emilmont 55:d722ed6a4237 59 * @param t Number of seconds since January 1, 1970 (the UNIX timestamp)
emilmont 44:24d45a770a51 60 *
emilmont 44:24d45a770a51 61 * Example:
emilmont 44:24d45a770a51 62 * @code
emilmont 44:24d45a770a51 63 * #include "mbed.h"
emilmont 44:24d45a770a51 64 *
emilmont 44:24d45a770a51 65 * int main() {
emilmont 44:24d45a770a51 66 * set_time(1256729737); // Set time to Wed, 28 Oct 2009 11:35:37
emilmont 44:24d45a770a51 67 * }
emilmont 44:24d45a770a51 68 * @endcode
emilmont 55:d722ed6a4237 69 */
emilmont 44:24d45a770a51 70 void set_time(time_t t);
emilmont 44:24d45a770a51 71
emilmont 44:24d45a770a51 72 #ifdef __cplusplus
emilmont 44:24d45a770a51 73 }
emilmont 44:24d45a770a51 74 #endif