Dependencies:   mbed

Committer:
Przemyslaw Stekiel
Date:
Tue Oct 23 12:08:10 2018 +0200
Revision:
5:0c6401d671c6
Parent:
2:c8b4159048f0
Child:
6:ffcfca43c247
fix compiler warning

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbedAustin 2:c8b4159048f0 1 /* mbed Example Program
mbedAustin 2:c8b4159048f0 2 * Copyright (c) 2006-2014 ARM Limited
mbedAustin 2:c8b4159048f0 3 *
mbedAustin 2:c8b4159048f0 4 * Licensed under the Apache License, Version 2.0 (the "License");
mbedAustin 2:c8b4159048f0 5 * you may not use this file except in compliance with the License.
mbedAustin 2:c8b4159048f0 6 * You may obtain a copy of the License at
mbedAustin 2:c8b4159048f0 7 *
mbedAustin 2:c8b4159048f0 8 * http://www.apache.org/licenses/LICENSE-2.0
mbedAustin 2:c8b4159048f0 9 *
mbedAustin 2:c8b4159048f0 10 * Unless required by applicable law or agreed to in writing, software
mbedAustin 2:c8b4159048f0 11 * distributed under the License is distributed on an "AS IS" BASIS,
mbedAustin 2:c8b4159048f0 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
mbedAustin 2:c8b4159048f0 13 * See the License for the specific language governing permissions and
mbedAustin 2:c8b4159048f0 14 * limitations under the License.
mbedAustin 2:c8b4159048f0 15 */
mbed_official 0:b3b93997a0a6 16 #include "mbed.h"
mbed_official 0:b3b93997a0a6 17
mbed_official 0:b3b93997a0a6 18 int main() {
mbed_official 0:b3b93997a0a6 19 set_time(1256729737); // Set RTC time to Wed, 28 Oct 2009 11:35:37
mbed_official 0:b3b93997a0a6 20
mbed_official 0:b3b93997a0a6 21 while (true) {
mbed_official 0:b3b93997a0a6 22 time_t seconds = time(NULL);
mbed_official 0:b3b93997a0a6 23
Przemyslaw Stekiel 5:0c6401d671c6 24 printf("Time as seconds since January 1, 1970 = %u\n", (unsigned int)seconds);
mbed_official 0:b3b93997a0a6 25
mbed_official 0:b3b93997a0a6 26 printf("Time as a basic string = %s", ctime(&seconds));
mbed_official 0:b3b93997a0a6 27
mbed_official 0:b3b93997a0a6 28 char buffer[32];
mbed_official 0:b3b93997a0a6 29 strftime(buffer, 32, "%I:%M %p\n", localtime(&seconds));
mbed_official 0:b3b93997a0a6 30 printf("Time as a custom formatted string = %s", buffer);
mbed_official 0:b3b93997a0a6 31
mbed_official 0:b3b93997a0a6 32 wait(1);
mbed_official 0:b3b93997a0a6 33 }
mbed_official 0:b3b93997a0a6 34 }