digitalmars.D - [your code here]
- Hello (12/12) May 03 2019 auto today()
- Bastiaan Veelo (9/21) May 04 2019 The cast is unnecessary, and there is writefln:
- Russel Winder (9/17) May 04 2019 "%04d-%02d-%02d" for ISO8601 compliance.
- Jonathan M Davis (7/33) May 09 2019 The cast isn't necessary, but it's more efficient. Internally, it basica...
- Jonathan M Davis (5/17) May 09 2019 If that's what you want, then just cast to Date and call toISOExtString(...
auto today() { import std.datetime; auto d = cast(DateTime) Clock.currTime(); import std.format: format; return format("%04d/%02d/%02d", d.year, d.month, d.day); } void main() { import std.stdio; today.writeln; }
May 03 2019
On Saturday, 4 May 2019 at 03:15:59 UTC, Hello wrote:auto today() { import std.datetime; auto d = cast(DateTime) Clock.currTime(); import std.format: format; return format("%04d/%02d/%02d", d.year, d.month, d.day); } void main() { import std.stdio; today.writeln; }The cast is unnecessary, and there is writefln: void main() { import std.datetime, std.stdio; auto d = Clock.currTime(); writefln("%04d/%02d/%02d", d.year, d.month, d.day); } https://run.dlang.io/is/wT6Cn7
May 04 2019
On Sat, 2019-05-04 at 08:06 +0000, Bastiaan Veelo via Digitalmars-d wrote:[=E2=80=A6] =20 void main() { import std.datetime, std.stdio; auto d =3D Clock.currTime(); writefln("%04d/%02d/%02d", d.year, d.month, d.day); }"%04d-%02d-%02d" for ISO8601 compliance. --=20 Russel. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Dr Russel Winder t: +44 20 7585 2200 41 Buckmaster Road m: +44 7770 465 077 London SW11 1EN, UK w: www.russel.org.uk
May 04 2019
On Saturday, May 4, 2019 2:06:59 AM MDT Bastiaan Veelo via Digitalmars-d wrote:On Saturday, 4 May 2019 at 03:15:59 UTC, Hello wrote:The cast isn't necessary, but it's more efficient. Internally, it basically doing the equivalent of casting to DateTime every time you ask for the pieces of the date/time such as the year or hour. So, whether is casting is better or not depends on whether you want shorter code or faster code. - Jonathan M Davisauto today() { import std.datetime; auto d = cast(DateTime) Clock.currTime(); import std.format: format; return format("%04d/%02d/%02d", d.year, d.month, d.day); } void main() { import std.stdio; today.writeln; }The cast is unnecessary, and there is writefln: void main() { import std.datetime, std.stdio; auto d = Clock.currTime(); writefln("%04d/%02d/%02d", d.year, d.month, d.day); } https://run.dlang.io/is/wT6Cn7
May 09 2019
On Saturday, May 4, 2019 5:17:57 AM MDT Russel Winder via Digitalmars-d wrote:On Sat, 2019-05-04 at 08:06 +0000, Bastiaan Veelo via Digitalmars-d wrote:If that's what you want, then just cast to Date and call toISOExtString() on it. - Jonathan M Davis[…] void main() { import std.datetime, std.stdio; auto d = Clock.currTime(); writefln("%04d/%02d/%02d", d.year, d.month, d.day); }"%04d-%02d-%02d" for ISO8601 compliance.
May 09 2019