Logo

Programming-Idioms

  • D
  • C
  • Cobol

Idiom #61 Get current date

Assign to the variable d the current date/time value, in the most standard type.

import std.datetime;
auto d = Clock.currTime;

Returns a struct representing the current system time in the appropriate timezone.
#include <time.h>
time_t d=time(0);

Unix Timestamp
IDENTIFICATION DIVISION.
PROGRAM-ID. date.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 curr-date.
   03 year      pic 9(4).
   03 month     pic 9(2).
   03 day       pic 9(2).
PROCEDURE DIVISION.
   MOVE FUNCTION CURRENT-DATE TO curr-date
STOP RUN.
with Ada.Calendar;
D : Ada.Calendar.Time := Ada.Calendar.Clock;

New implementation...
< >
programming-idioms.org