osmium::Timestamp Class Reference

`#include <timestamp.hpp>`

## Public Member Functions

constexpr | Timestamp () noexcept
template<typename T , typename std::enable_if< std::is_integral< T >::value, int >::type = 0>
constexpr | Timestamp (T timestamp) noexcept
| Timestamp (const char *timestamp)
| Timestamp (const std::string &timestamp)
bool | valid () const noexcept
constexpr | operator bool () const noexcept
| Explicit conversion into bool. More...
constexpr time_t | seconds_since_epoch () const noexcept
| Explicit conversion into time_t. More...
constexpr | operator uint32_t () const noexcept
| Explicit conversion into uint32_t. More...
constexpr | operator uint64_t () const noexcept
| Explicit conversion into uint64_t. More...
OSMIUM_DEPRECATED constexpr | operator time_t () const noexcept
template<typename T >
void | operator+= (T time_difference) noexcept
template<typename T >
void | operator-= (T time_difference) noexcept
std::string | to_iso () const

## Static Private Member Functions

static const char * | timestamp_format ()

## Private Attributes

uint32_t | m_timestamp

## Static Private Attributes

static constexpr int | timestamp_length = 20 + 1

## Detailed Description

A timestamp. Internal representation is an unsigned 32bit integer holding seconds since epoch (1970-01-01T00:00:00Z), so this will overflow in 2106. We can use an unsigned integer here, because the OpenStreetMap project was started long after 1970, so there will never be dates before that.

## Constructor & Destructor Documentation

constexpr osmium::Timestamp::Timestamp | ( |  | ) |

inline noexcept

Default construct an invalid Timestamp.

template<typename T , typename std::enable_if< std::is_integral< T >::value, int >::type = 0>

constexpr osmium::Timestamp::Timestamp | ( | T | timestamp | ) |

inline noexcept

Construct a Timestamp from any integer type containing the seconds since the epoch. This will not check for overruns, you have to make sure the value fits into a uint32_t which is used internally in the Timestamp.

The constructor is not declared "explicit" so that conversions like

node.set_timestamp(123);

work.

osmium::Timestamp::Timestamp | ( | const char * | timestamp | ) |

inline explicit

Construct timestamp from ISO date/time string in the format "yyyy-mm-ddThh:mm:ssZ".

Exceptions

  std::invalid_argument | if the timestamp can not be parsed.

osmium::Timestamp::Timestamp | ( | const std::string & | timestamp | ) |

inline explicit

Construct timestamp from ISO date/time string in the format "yyyy-mm-ddThh:mm:ssZ".

Exceptions

  std::invalid_argument | if the timestamp can not be parsed.

## Member Function Documentation

constexpr osmium::Timestamp::operator bool | ( |  | ) | const

inline explicit noexcept

Explicit conversion into bool.

OSMIUM_DEPRECATED constexpr osmium::Timestamp::operator time_t | ( |  | ) | const

inline noexcept

Implicit conversion into time_t.

Deprecated:
  You should call seconds_since_epoch() explicitly instead.

constexpr osmium::Timestamp::operator uint32_t | ( |  | ) | const

inline explicit noexcept

Explicit conversion into uint32_t.

constexpr osmium::Timestamp::operator uint64_t | ( |  | ) | const

inline explicit noexcept

Explicit conversion into uint64_t.

template<typename T >

void osmium::Timestamp::operator+= | ( | T | time_difference | ) |

inline noexcept

template<typename T >

void osmium::Timestamp::operator-= | ( | T | time_difference | ) |

inline noexcept

constexpr time_t osmium::Timestamp::seconds_since_epoch | ( |  | ) | const

inline noexcept

Explicit conversion into time_t.

static const char* osmium::Timestamp::timestamp_format | ( |  | ) |

inline static private

std::string osmium::Timestamp::to_iso | ( |  | ) | const

inline

Return the timestamp as string in ISO date/time ("yyyy-mm-ddThh:mm:ssZ") format. If the timestamp is invalid, an empty string will be returned.

bool osmium::Timestamp::valid | ( |  | ) | const

inline noexcept

Returns true if this timestamp is valid (ie set to something other than 0).

## Member Data Documentation

uint32_t osmium::Timestamp::m_timestamp

private

constexpr int osmium::Timestamp::timestamp_length = 20 + 1

static private

The documentation for this class was generated from the following file:

- osmium/osm/timestamp.hpp