Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Among the many improvements, time is one area where C++ has become better than old school C cruft. In c++20/std::chrono, the Lua like code is just this -

  auto now = system_clock::now();
  zoned_time local_time{current_zone(), now};
  std::cout << std::format("{:%a %b %d %T}\n", local_time);


Some C++23 flavour, :)

  auto now = system_clock::now();
  zoned_time local_time{current_zone(), now};
  std::println("{:%a %b %d %T}", local_time);


Or Rust, with Jiff:

    println!("{}", jiff::Zoned::now().strftime("%a %b %d %T"));




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: