• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

realm / realm-core / github_pull_request_312964

19 Feb 2025 07:31PM UTC coverage: 90.814% (-0.3%) from 91.119%
github_pull_request_312964

Pull #8071

Evergreen

web-flow
Bump serialize-javascript and mocha

Bumps [serialize-javascript](https://github.com/yahoo/serialize-javascript) to 6.0.2 and updates ancestor dependency [mocha](https://github.com/mochajs/mocha). These dependencies need to be updated together.


Updates `serialize-javascript` from 6.0.0 to 6.0.2
- [Release notes](https://github.com/yahoo/serialize-javascript/releases)
- [Commits](https://github.com/yahoo/serialize-javascript/compare/v6.0.0...v6.0.2)

Updates `mocha` from 10.2.0 to 10.8.2
- [Release notes](https://github.com/mochajs/mocha/releases)
- [Changelog](https://github.com/mochajs/mocha/blob/main/CHANGELOG.md)
- [Commits](https://github.com/mochajs/mocha/compare/v10.2.0...v10.8.2)

---
updated-dependencies:
- dependency-name: serialize-javascript
  dependency-type: indirect
- dependency-name: mocha
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #8071: Bump serialize-javascript and mocha

96552 of 179126 branches covered (53.9%)

212672 of 234185 relevant lines covered (90.81%)

3115802.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/realm/util/timestamp_formatter.cpp
1
#include <locale>
2
#include <stdexcept>
3
#include <iomanip>
4

5
#include <realm/util/time.hpp>
6
#include <realm/util/timestamp_formatter.hpp>
7

8
using namespace realm;
9
using util::TimestampFormatter;
10

11

12
TimestampFormatter::TimestampFormatter(Config config)
13
    : m_utc_time{config.utc_time}
×
14
    , m_precision{config.precision}
×
15
    , m_format_segments{make_format_segments(config)} // Throws
×
16
{
×
17
    m_out.imbue(std::locale::classic());
×
18
    m_out.fill('0');
×
19
}
×
20

21

22
auto TimestampFormatter::format(std::time_t time, long nanoseconds) -> string_view_type
23
{
×
24
    std::tm time_2 = (m_utc_time ? util::gmtime(time) : util::localtime(time));
×
25
    m_out.set_buffer(m_buffer, m_buffer + sizeof m_buffer / sizeof m_buffer[0]);
×
26
    util::put_time(m_out, time_2, m_format_segments.first.c_str());
×
27
    switch (m_precision) {
×
28
        case Precision::seconds:
×
29
            break;
×
30
        case Precision::milliseconds:
×
31
            m_out << '.' << std::setw(3) << (nanoseconds / 1000000);
×
32
            break;
×
33
        case Precision::microseconds:
×
34
            m_out << '.' << std::setw(6) << (nanoseconds / 1000);
×
35
            break;
×
36
        case Precision::nanoseconds:
×
37
            m_out << '.' << std::setw(9) << nanoseconds;
×
38
            break;
×
39
    }
×
40
    util::put_time(m_out, time_2, m_format_segments.second);
×
41
    if (!m_out)
×
42
        throw std::runtime_error("Failed to format timestamp");
×
43
    return string_view_type{m_buffer, m_out.size()};
×
44
}
×
45

46

47
auto TimestampFormatter::make_format_segments(const Config& config) -> format_segments_type
48
{
×
49
    const char* i = config.format;
×
50
    for (;;) {
×
51
        char ch = *i++;
×
52
        if (REALM_UNLIKELY(ch == '%')) {
×
53
            ch = *i++;
×
54
            if (ch == 'S' || ch == 'T')
×
55
                break;
×
56
        }
×
57
        if (REALM_UNLIKELY(ch == '\0'))
×
58
            return {std::string{}, config.format};
×
59
    }
×
60
    return {std::string{config.format, i}, i}; // Throws
×
61
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc