Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
main.cpp@2:c8b4159048f0, 2015-03-27 (annotated)
- Committer:
- mbedAustin
- Date:
- Fri Mar 27 20:18:01 2015 +0000
- Revision:
- 2:c8b4159048f0
- Parent:
- 0:b3b93997a0a6
- Child:
- 5:0c6401d671c6
Added license to main.c file.
Who changed what in which revision?
| User | Revision | Line number | New 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 | |
| mbed_official | 0:b3b93997a0a6 | 24 | printf("Time as seconds since January 1, 1970 = %d\n", 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 | } |