File: date.hpp

package info (click to toggle)
polybar 3.7.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,108 kB
  • sloc: cpp: 30,424; python: 3,750; sh: 284; makefile: 83
file content (51 lines) | stat: -rw-r--r-- 1,066 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#pragma once

#include <atomic>
#include <ctime>
#include <iomanip>
#include <iostream>

#include "modules/meta/timer_module.hpp"
#include "modules/meta/types.hpp"

POLYBAR_NS

namespace modules {
  class date_module : public timer_module<date_module> {
   public:
    explicit date_module(const bar_settings&, string, const config&);

    bool update();
    bool build(builder* builder, const string& tag) const;

    static constexpr auto TYPE = DATE_TYPE;

    static constexpr auto EVENT_TOGGLE = "toggle";

   protected:
    void action_toggle();

   private:
    static constexpr auto TAG_LABEL = "<label>";

    // @deprecated: Use <label>
    static constexpr auto TAG_DATE = "<date>";

    label_t m_label;

    string m_dateformat;
    string m_dateformat_alt;
    string m_timeformat;
    string m_timeformat_alt;

    string m_date;
    string m_time;

    // Single stringstream to be used to gather the results of std::put_time
    std::stringstream datetime_stream;

    std::atomic<bool> m_toggled{false};
  };
} // namespace modules

POLYBAR_NS_END