Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,2 @@
---
from: http://rosettacode.org/wiki/Show_the_epoch

View file

@ -0,0 +1,12 @@
;Task:
Choose popular date libraries used by your language and show the   [[wp:Epoch_(reference_date)#Computing|epoch]]   those libraries use.
A demonstration is preferable   (e.g. setting the internal representation of the date to 0 ms/ns/etc.,   or another way that will still show the epoch even if it is changed behind the scenes by the implementers),   but text from (with links to) documentation is also acceptable where a demonstration is impossible/impractical.
For consistency's sake, show the date in UTC time where possible.
;Related task:
*   [[Date format]]
<br><br>

View file

@ -0,0 +1,5 @@
DATA: lv_date TYPE datum.
lv_date = 0.
WRITE: / lv_date.

View file

@ -0,0 +1 @@
cl_demo_output=>display( |Result: { CONV datum( 0 ) }| ).

View file

@ -0,0 +1,6 @@
# syntax: GAWK -f SHOW_THE_EPOCH.AWK
# requires GNU Awk 4.0.1 or later
BEGIN {
print(strftime("%Y-%m-%d %H:%M:%S",0,1))
exit(0)
}

View file

@ -0,0 +1,9 @@
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Calendar; use Ada.Calendar;
with Ada.Calendar.Formatting; use Ada.Calendar.Formatting;
with Ada.Calendar.Conversions; use Ada.Calendar.Conversions;
procedure ShowEpoch is
etime : Time := To_Ada_Time (0);
begin
Put_Line (Image (Date => etime));
end ShowEpoch;

View file

@ -0,0 +1,15 @@
use AppleScript version "2.4" -- OS X 10.10 (Yosemite) or later
use framework "Foundation"
use scripting additions
local CocoaEpoch, UnixEpoch
-- Get the date 0 seconds from the Cocoa epoch.
set CocoaEpoch to current application's class "NSDate"'s dateWithTimeIntervalSinceReferenceDate:(0)
-- The way it's rendered in its 'description' is good enough for the current purpose.
set CocoaEpoch to CocoaEpoch's |description|() as text
-- Get the date 0 seconds from the Unix epoch and format it in the same way.
set UnixEpoch to (do shell script "date -ur 0 '+%F %T %z'")
return "Cocoa epoch: " & CocoaEpoch & linefeed & "Unix epoch: " & UnixEpoch

View file

@ -0,0 +1,2 @@
"Cocoa epoch: 2001-01-01 00:00:00 +0000
Unix epoch: 1970-01-01 00:00:00 +0000"

View file

@ -0,0 +1,4 @@
print to :date 0 ; convert UNIX timestamp: 0 to date
print now
print to :integer now ; convert current date to UNIX timestamp

View file

@ -0,0 +1,2 @@
INSTALL @lib$+"DATELIB"
PRINT FN_date$(0, "dd-MMM-yyyy")

View file

@ -0,0 +1,10 @@
#include <iostream>
#include <chrono>
#include <ctime>
int main()
{
std::chrono::system_clock::time_point epoch;
std::time_t t = std::chrono::system_clock::to_time_t(epoch);
std::cout << std::asctime(std::gmtime(&t)) << '\n';
return 0;
}

View file

@ -0,0 +1,7 @@
#include <iostream>
#include <boost/date_time.hpp>
int main()
{
std::cout << boost::posix_time::ptime( boost::posix_time::min_date_time ) << '\n';
return 0;
}

View file

@ -0,0 +1,9 @@
using System;
class Program
{
static void Main()
{
Console.WriteLine(new DateTime());
}
}

View file

@ -0,0 +1,8 @@
#include <time.h>
#include <stdio.h>
int main() {
time_t t = 0;
printf("%s", asctime(gmtime(&t)));
return 0;
}

View file

@ -0,0 +1,34 @@
#include <windows.h>
#include <stdio.h>
#include <wchar.h>
int
main()
{
FILETIME ft = {dwLowDateTime: 0, dwHighDateTime: 0}; /* Epoch */
SYSTEMTIME st;
wchar_t date[80], time[80];
/*
* Convert FILETIME (which counts 100-nanosecond intervals since
* the epoch) to SYSTEMTIME (which has year, month, and so on).
*
* The time is in UTC, because we never call
* SystemTimeToTzSpecificLocalTime() to convert it to local time.
*/
FileTimeToSystemTime(&ft, &st);
/*
* Format SYSTEMTIME as a string.
*/
if (GetDateFormatW(LOCALE_USER_DEFAULT, DATE_LONGDATE, &st, NULL,
date, sizeof date / sizeof date[0]) == 0 ||
GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &st, NULL,
time, sizeof time / sizeof time[0]) == 0) {
fwprintf(stderr, L"Error!\n");
return 1;
}
wprintf(L"FileTime epoch is %ls, at %ls (UTC).\n", date, time);
return 0;
}

View file

@ -0,0 +1,17 @@
IDENTIFICATION DIVISION.
PROGRAM-ID. epoch.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 epoch-date.
03 year PIC 9(4).
03 month PIC 99.
03 dday PIC 99.
PROCEDURE DIVISION.
MOVE FUNCTION DATE-OF-INTEGER(1) TO epoch-date
DISPLAY year "-" month "-" dday
GOBACK
.

View file

@ -0,0 +1 @@
(println (java.util.Date. 0))

View file

@ -0,0 +1 @@
#inst "1970-01-01T00:00:00.000-00:00"

View file

@ -0,0 +1 @@
console.log new Date(0).toISOString()

View file

@ -0,0 +1,2 @@
(multiple-value-bind (second minute hour day month year) (decode-universal-time 0 0)
(format t "~4,'0D-~2,'0D-~2,'0D ~2,'0D:~2,'0D:~2,'0D" year month day hour minute second))

View file

@ -0,0 +1,3 @@
main() {
print(new Date.fromEpoch(0,new TimeZone.utc()));
}

View file

@ -0,0 +1,9 @@
program ShowEpoch;
{$APPTYPE CONSOLE}
uses SysUtils;
begin
Writeln(FormatDateTime('yyyy-mm-dd hh:nn:ss.zzz', 0));
end.

View file

@ -0,0 +1 @@
printfn "%s" ((new System.DateTime()).ToString("u"))

View file

@ -0,0 +1,3 @@
USING: calendar calendar.format io ;
0 micros>timestamp timestamp>ymdhms print

View file

@ -0,0 +1,2 @@
include lib/longjday.4th
0 posix>jday .longjday cr

View file

@ -0,0 +1,16 @@
' FB 1.05.0 Win64
#Include "vbcompat.bi"
' The first argument to the Format function is a date serial
' and so the first statement below displays the epoch.
Dim f As String = "mmmm d, yyyy hh:mm:ss"
Print Format( 0 , f) '' epoch
Print Format( 0.5, f) '' noon on the same day
Print Format(-0.5, f) '' noon on the previous day
Print Format(1000000, f) '' one million days after the epoch
Print Format(-80000, f) '' eighty thousand days before the epoch
Print
Print "Press any key to quit"
Sleep

View file

@ -0,0 +1 @@
println[ JD[0 s] -> UTC ]

View file

@ -0,0 +1,2 @@
epoch = # 1970 UTC #
now[] - epoch -> ns

View file

@ -0,0 +1,2 @@
epoch = # 1970 UTC #
epoch + 2 billion seconds -> Japan

View file

@ -0,0 +1,17 @@
window 1
print date$
print date$("d MMM yyyy")
print date$("EEE, MMM d, yyyy")
print date$("MMMM d, yyyy ")
print date$("MMMM d, yyyy G")
print "This is day ";date$("D");" of the year"
print
print time$
print time$("hh:mm:ss")
print time$("h:mm a")
print time$("h:mm a zzz")
print
print time$("h:mm a ZZZZ "); date$("MMMM d, yyyy G")
HandleEvents

View file

@ -0,0 +1,6 @@
package main
import ("fmt"; "time")
func main() {
fmt.Println(time.Time{})
}

View file

@ -0,0 +1,4 @@
def date = new Date(0)
def format = new java.text.SimpleDateFormat('yyyy-MM-dd\'T\'HH:mm:ss.SSSZ')
format.timeZone = TimeZone.getTimeZone('UTC')
println (format.format(date))

View file

@ -0,0 +1,3 @@
import System.Time
main = putStrLn $ calendarTimeToString $ toUTCTime $ TOD 0 0

View file

@ -0,0 +1,3 @@
import Data.Time
main = print $ UTCTime (ModifiedJulianDay 0) 0

View file

@ -0,0 +1,12 @@
link printf,datetime
procedure main()
# Unicon
now := gettimeofday().sec
if now = &now then printf("&now and gettimeofday().sec are equal\n")
printf("Now (UTC) %s, (local) %s\n",gtime(now),ctime(now))
printf("Epoch %s\n",gtime(0))
# Icon and Unicon
now := DateToSec(&date) + ClockToSec(&clock)
printf("Now is also %s and %s\n",SecToDate(now),SecToDateLine(now))
end

View file

@ -0,0 +1,2 @@
6!:0''
2011 8 8 20 25 44.725

View file

@ -0,0 +1,3 @@
require'dates'
todate 0
1800 1 1

View file

@ -0,0 +1,12 @@
import java.text.DateFormat;
import java.util.Date;
import java.util.TimeZone;
public class DateTest{
public static void main(String[] args) {
Date date = new Date(0);
DateFormat format = DateFormat.getDateTimeInstance();
format.setTimeZone(TimeZone.getTimeZone("UTC"));
System.out.println(format.format(date));
}
}

View file

@ -0,0 +1 @@
document.write(new Date(0).toUTCString());

View file

@ -0,0 +1 @@
0 | todate

View file

@ -0,0 +1 @@
"1970-01-01T00:00:00Z"

View file

@ -0,0 +1,2 @@
using Base.Dates # just using Dates in versions > 0.6
println("Time zero (the epoch) is $(unix2datetime(0)).")

View file

@ -0,0 +1,12 @@
// version 1.1.2
import java.util.Date
import java.util.TimeZone
import java.text.DateFormat
fun main( args: Array<String>) {
val epoch = Date(0)
val format = DateFormat.getDateTimeInstance()
format.timeZone = TimeZone.getTimeZone("UTC")
println(format.format(epoch))
}

View file

@ -0,0 +1,2 @@
date(0.00)
date(0)

View file

@ -0,0 +1,17 @@
implement Epoch;
include "sys.m"; sys: Sys;
include "draw.m";
include "daytime.m"; daytime: Daytime;
Tm: import daytime;
Epoch: module {
init: fn(nil: ref Draw->Context, nil: list of string);
};
init(nil: ref Draw->Context, nil: list of string)
{
sys = load Sys Sys->PATH;
daytime = load Daytime Daytime->PATH;
sys->print("%s\n", daytime->text(daytime->gmt(0)));
}

View file

@ -0,0 +1,34 @@
implement Epoch;
include "sys.m"; sys: Sys;
include "draw.m";
include "daytime.m"; daytime: Daytime;
Tm: import daytime;
Epoch: module {
init: fn(nil: ref Draw->Context, nil: list of string);
};
init(nil: ref Draw->Context, nil: list of string)
{
sys = load Sys Sys->PATH;
daytime = load Daytime Daytime->PATH;
# Create a file containing a zero:
fd := sys->open("/tmp/0", Sys->OWRITE);
if(fd == nil) {
sys->fprint(sys->fildes(2), "Couldn't open /tmp/0 for writing: %r\n");
raise "fail:errors";
}
sys->fprint(fd, "0");
fd = nil; # Files with no references are closed immediately.
# Fork the namespace so as not to disturb the parent
# process's concept of time:
sys->pctl(Sys->FORKNS, nil);
# Bind that file over /dev/time:
sys->bind("/tmp/0", "/dev/time", Sys->MREPL);
# Print the "current" date, now the epoch:
sys->print("%s\n", daytime->text(daytime->gmt(daytime->now())));
}

View file

@ -0,0 +1,9 @@
now = the systemDate
put now
-- date( 2018, 3, 21 )
babylonianDate = date(-1800,1,1)
-- print approx. year difference between "babylonianDate" and now
put (now-babylonianDate)/365.2425
-- 3818.1355

View file

@ -0,0 +1,6 @@
put 0 into somedate
convert somedate to internet date
put somedate
-- output GMT (localised)
-- Thu, 1 Jan 1970 10:00:00 +1000

View file

@ -0,0 +1,17 @@
Sub Click(Source As Button)
'Create timestamp as of now
Dim timeStamp As NotesDateTime
Set timeStamp = New NotesDateTime ( Now )
'Assign epoch start time to variable
Dim epochTime As NotesDateTime
Set epochTime = New NotesDateTime ( "01/01/1970 00:00:00 AM GMT" ) ''' These two commands only to get epoch time.
'Calculate time difference between both dates
Dim epochSeconds As Long
epochSeconds = timeStamp.TimeDifference ( epochTime )
'Print result
Print epochSeconds
End Sub

View file

@ -0,0 +1 @@
print(os.date("%c", 0))

View file

@ -0,0 +1,5 @@
d = [0,1,2,3.5,-3.5,1000*365,1000*366,now+[-1,0,1]];
for k=1:length(d)
printf('day %f\t%s\n',d(k),datestr(d(k),0))
disp(datevec(d(k)))
end;

View file

@ -0,0 +1 @@
DateString[0]

View file

@ -0,0 +1,2 @@
timedate(0);
"1900-01-01 10:00:00+10:00"

View file

@ -0,0 +1 @@
0 datetime puts!

View file

@ -0,0 +1,10 @@
/* NetRexx */
options replace format comments java crossref symbols nobinary
import java.text.DateFormat
edate = Date(0)
zulu = DateFormat.getDateTimeInstance()
zulu.setTimeZone(TimeZone.getTimeZone('UTC'))
say zulu.format(edate)
return

View file

@ -0,0 +1,2 @@
(date 0)
->"Thu Jan 01 01:00:00 1970"

View file

@ -0,0 +1,4 @@
import times
echo "Epoch for Posix systems: ", fromUnix(0).utc
echo "Epoch for Windows system: ", fromWinTime(0).utc

View file

@ -0,0 +1,8 @@
open Unix
let months = [| "January"; "February"; "March"; "April"; "May"; "June";
"July"; "August"; "September"; "October"; "November"; "December" |]
let () =
let t = Unix.gmtime 0.0 in
Printf.printf "%s %d, %d\n" months.(t.tm_mon) t.tm_mday (1900 + t.tm_year)

View file

@ -0,0 +1,14 @@
#import <Foundation/Foundation.h>
int main(int argc, const char *argv[]) {
@autoreleasepool {
NSDate *t = [NSDate dateWithTimeIntervalSinceReferenceDate:0];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setTimeZone:[NSTimeZone timeZoneWithName:@"UTC"]];
[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss ZZ"];
NSLog(@"%@", [dateFormatter stringFromDate:t]);
}
return 0;
}

View file

@ -0,0 +1,3 @@
import: date
0 asDateUTC println

View file

@ -0,0 +1 @@
system("date -ur 0")

View file

@ -0,0 +1,3 @@
<?php
echo gmdate('r', 0), "\n";
?>

View file

@ -0,0 +1,17 @@
*process source attributes xref;
epoch: Proc Options(main);
/*********************************************************************
* 20.08.2013 Walter Pachl shows that PL/I uses 15 Oct 1582 as epoch
* DAYS returns a FIXED BINARY(31,0) value which is the number of days
* (in Lilian format) corresponding to the date d.
*********************************************************************/
Dcl d Char(17);
Put Edit(datetime(),days(datetime()))
(Skip,a,f(15));
d='15821015000000000';
Put Edit(d ,days(d))
(Skip,a,f(15));
d='15821014000000000';
Put Edit(d ,days(d))
(Skip,a,f(15));
End;

View file

@ -0,0 +1,9 @@
Program ShowEpoch;
uses
SysUtils;
begin
Writeln(FormatDateTime('yyyy-mm-dd hh:nn:ss.zzz', Now));
Writeln(FormatDateTime('yyyy-mm-dd hh:nn:ss.zzz', 0));
end.

View file

@ -0,0 +1 @@
print scalar gmtime 0, "\n";

View file

@ -0,0 +1,7 @@
(phixonline)-->
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #008080;">constant</span> <span style="color: #000000;">d0</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #000000;">1</span><span style="color: #0000FF;">}</span>
<span style="color: #008080;">include</span> <span style="color: #000000;">builtins</span><span style="color: #0000FF;">\</span><span style="color: #004080;">timedate</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span>
<span style="color: #0000FF;">?</span><span style="color: #7060A8;">format_timedate</span><span style="color: #0000FF;">(</span><span style="color: #000000;">d0</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"YYYY-MM-DD"</span><span style="color: #0000FF;">)</span>
<span style="color: #0000FF;">?</span><span style="color: #7060A8;">format_timedate</span><span style="color: #0000FF;">(</span><span style="color: #000000;">d0</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Dddd, Mmmm d, YYYY"</span><span style="color: #0000FF;">)</span>
<!--

View file

@ -0,0 +1,2 @@
: (date 1)
-> (0 3 1) # Year zero, March 1st

View file

@ -0,0 +1,2 @@
object cal = Calendar.ISO->set_timezone("UTC");
write( cal.Second(0)->format_iso_short() );

View file

@ -0,0 +1 @@
[datetime] 0

View file

@ -0,0 +1 @@
Get-Date -Year 1 -Month 1 -Day 1 -Hour 0 -Minute 0 -Second 0 -Millisecond 0

View file

@ -0,0 +1 @@
New-Object -TypeName System.DateTime

View file

@ -0,0 +1 @@
New-Object -TypeName System.DateTime -ArgumentList 1, 1, 1, 0, 0, 0, ([DateTimeKind]::Utc) | Format-List

View file

@ -0,0 +1,6 @@
If OpenConsole()
PrintN(FormatDate("Y = %yyyy M = %mm D = %dd, %hh:%ii:%ss", 0))
Print(#CRLF$ + #CRLF$ + "Press ENTER to exit"): Input()
CloseConsole()
EndIf

View file

@ -0,0 +1,4 @@
>>> import time
>>> time.asctime(time.gmtime(0))
'Thu Jan 1 00:00:00 1970'
>>>

View file

@ -0,0 +1,4 @@
> epoch <- 0
> class(epoch) <- class(Sys.time())
> format(epoch, "%Y-%m-%d %H:%M:%S %Z")
[1] "1970-01-01 00:00:00 UTC"

View file

@ -0,0 +1,11 @@
/*REXX program displays the number of days since the epoch for the DATE function (BIF). */
say ' today is: ' date() /*today's is format: mm MON YYYY */
days=date('Basedate') /*only the first char of option is used*/
say right(days, 40) " days since the REXX base date of January 1st, year 1"
say ' and today is: ' date(, days, "B") /*it should still be today (µSec later)*/
/* ↑ ┌───◄─── This BIF (Built-In Function) is only */
/* └─────────◄──────┘ for newer versions of REXX that */
/* support the 2nd and 3rd arguments. */

View file

@ -0,0 +1,3 @@
#lang racket
(require racket/date)
(date->string (seconds->date 0 #f))

View file

@ -0,0 +1 @@
say DateTime.new(0)

View file

@ -0,0 +1,14 @@
load "guilib.ring"
New qApp {
win1 = new qMainWindow() {
setwindowtitle("Using QDateEdit")
setGeometry(100,100,250,100)
oDate = new qdateedit(win1) {
setGeometry(20,40,220,30)
oDate.minimumDate()
}
show()
}
exec()
}

View file

@ -0,0 +1,2 @@
irb(main):001:0> Time.at(0).utc
=> 1970-01-01 00:00:00 UTC

View file

@ -0,0 +1,2 @@
require "date"
Date.new # => #<Date: -4712-01-01 ((0j,0s,0n),+0s,2299161j)>

View file

@ -0,0 +1,3 @@
eDate$ = date$("01/01/0001")
cDate$ = date$(0) ' 01/01/1901
sDate$ = date$("01/01/1970")

View file

@ -0,0 +1,8 @@
extern crate time;
use time::{at_utc, Timespec};
fn main() {
let epoch = at_utc(Timespec::new(0, 0));
println!("{}", epoch.asctime());
}

View file

@ -0,0 +1,6 @@
import java.util.{Date, TimeZone, Locale}
import java.text.DateFormat
val df=DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, Locale.ENGLISH)
df.setTimeZone(TimeZone.getTimeZone("UTC"))
println(df.format(new Date(0)))

View file

@ -0,0 +1,2 @@
; Display date at Time Zero in UTC.
(printf "~s~%" (time-utc->date (make-time 'time-utc 0 0) 0))

View file

@ -0,0 +1,7 @@
$ include "seed7_05.s7i";
include "time.s7i";
const proc: main is func
begin
writeln(time.value);
end func;

View file

@ -0,0 +1 @@
say Time.new(0).gmtime.ctime;

View file

@ -0,0 +1,2 @@
- Date.toString (Date.fromTimeUniv Time.zeroTime);
val it = "Thu Jan 1 00:00:00 1970" : string

View file

@ -0,0 +1,4 @@
. di %td 0
01jan1960
. di %tc 0
01jan1960 00:00:00

View file

@ -0,0 +1,10 @@
$$ MODE TUSCRIPT
- epoch
number=1
dayofweeknr=DATE (date,day,month,year,number)
epoch=JOIN(year,"-",month,day)
PRINT "epoch: ", epoch," (daynumber ",number,")"
- today's daynumber
dayofweeknr=DATE (today,day,month,year,number)
date=JOIN (year,"-",month,day)
PRINT "today's date: ", date," (daynumber ", number,")"

View file

@ -0,0 +1,2 @@
% clock format 0 -gmt 1
Thu Jan 01 00:00:00 GMT 1970

View file

@ -0,0 +1,2 @@
$ date -ur 0
Thu Jan 1 00:00:00 UTC 1970

View file

@ -0,0 +1,2 @@
$ TZ=UTC date --date "$(date +%s) seconds ago"
Thu Jan 1 00:00:00 UTC 1970

View file

@ -0,0 +1,3 @@
Sub Main()
Debug.Print Format(0, "dd mmm yyyy hh:mm")
End Sub

View file

@ -0,0 +1,8 @@
import "/date" for Date
Date.default = Date.isoFull
var dt = Date.fromNumber(0)
System.print(dt)
var dt2 = Date.unixEpoch
System.print(dt2)

View file

@ -0,0 +1,2 @@
zkl: Time.Clock.tickToTock(0,False)
L(1970,1,1,0,0,0) // y,m,d, h,m,s