Loading...
Searching...
No Matches
osmium::Timestamp Class Reference

`#include <timestamp.hpp>`

## Public Member Functions

constexpr | Timestamp () noexcept=default
template<typename T, typename std::enable_if_t< std::is_integral< T >::value, int > = 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.
constexpr std::time_t | seconds_since_epoch () const noexcept
| Explicit conversion into time_t.
constexpr | operator uint32_t () const noexcept
| Explicit conversion into uint32_t.
constexpr | operator uint64_t () const noexcept
| Explicit conversion into uint64_t.
template<typename T>
void | operator+= (T time_difference) noexcept
template<typename T>
void | operator-= (T time_difference) noexcept
std::string | to_iso () const
std::string | to_iso_all () const

## Private Member Functions

void | to_iso_str (std::string &s) const

## Private Attributes

uint32_t | m_timestamp = 0

## 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

## Timestamp() [1/4]

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

constexpr default noexcept

Default construct an invalid Timestamp.

## Timestamp() [2/4]

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

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

inline constexpr 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);
osmium::item_type::node
@ node
Definition item_type.hpp:48

work.

## Timestamp() [3/4]

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.

## Timestamp() [4/4]

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

## operator bool()

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

inline explicit constexpr noexcept

Explicit conversion into bool.

## operator uint32_t()

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

inline explicit constexpr noexcept

Explicit conversion into uint32_t.

## operator uint64_t()

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

inline explicit constexpr noexcept

Explicit conversion into uint64_t.

## operator+=()

template<typename T>

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

inline noexcept

## operator-=()

template<typename T>

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

inline noexcept

## seconds_since_epoch()

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

inline constexpr noexcept

Explicit conversion into time_t.

## to_iso()

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.

## to_iso_all()

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

inline

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

## to_iso_str()

void osmium::Timestamp::to_iso_str | ( | std::string & | s | ) | const

inline private

## valid()

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

inline noexcept

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

## Member Data Documentation

## m_timestamp

uint32_t osmium::Timestamp::m_timestamp = 0

private

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

- include/osmium/osm/timestamp.hpp