Format std::time output

You can use the crate chrono to achieve the same result: extern crate chrono; use chrono::Local; fn main() { let date = Local::now(); println!(“{}”, date.format(“%Y-%m-%d][%H:%M:%S”)); } Edit: The time crate is not deprecated: it is unmaintained. Besides, it is not possible to format a time using only the standard library.

What is the maximum value of a number in Lua?

as compiled by default, the Number is a double, on most compilers that’s an IEEE 64-bit floating point. that means 10bit exponent, so the maximum number is roughly 2^1024, or 5.6e300 years. that’s a long time. now, if you’re incrementing it, you might be more interested in the integer range. the 52-bit mantissa means that … Read more

DateTime Flutter

Using the answer here and changing it a bit:- You can try the following: import ‘package:flutter/material.dart’; import ‘package:intl/intl.dart’; void main() { runApp(TabBarDemo()); } class TabBarDemo extends StatelessWidget { @override Widget build(BuildContext context) { DateTime now = DateTime.now(); String formattedDate = DateFormat(‘kk:mm:ss \n EEE d MMM’).format(now); return MaterialApp( home: DefaultTabController( length: 3, child: Scaffold( appBar: AppBar( … Read more

Convert UTC to “local” time in Go

Keep in mind that the playground has the time set to 2009-11-10 23:00:00 +0000 UTC, so it is working. The proper way is to use time.LoadLocation though, here’s an example: var countryTz = map[string]string{ “Hungary”: “Europe/Budapest”, “Egypt”: “Africa/Cairo”, } func timeIn(name string) time.Time { loc, err := time.LoadLocation(countryTz[name]) if err != nil { panic(err) } … Read more

How do you time a function in Go and return its runtime in milliseconds?

Go’s defer makes this trivial. In Go 1.x, define the following functions: func trace(s string) (string, time.Time) { log.Println(“START:”, s) return s, time.Now() } func un(s string, startTime time.Time) { endTime := time.Now() log.Println(” END:”, s, “ElapsedTime in seconds:”, endTime.Sub(startTime)) } After that, you get Squeaky Clean one line elapsed time log messages: func someFunction() … Read more

Groovy time durations

If you just want to find the difference between two times you create yourself (for instance to see how long something takes to execute) you could use: import groovy.time.* def timeStart = new Date() // Some code you want to time def timeStop = new Date() TimeDuration duration = TimeCategory.minus(timeStop, timeStart) println duration If you … Read more

tech