Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
2
Task/Show-the-epoch/00-META.yaml
Normal file
2
Task/Show-the-epoch/00-META.yaml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
from: http://rosettacode.org/wiki/Show_the_epoch
|
||||
12
Task/Show-the-epoch/00-TASK.txt
Normal file
12
Task/Show-the-epoch/00-TASK.txt
Normal 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>
|
||||
|
||||
5
Task/Show-the-epoch/ABAP/show-the-epoch-1.abap
Normal file
5
Task/Show-the-epoch/ABAP/show-the-epoch-1.abap
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
DATA: lv_date TYPE datum.
|
||||
|
||||
lv_date = 0.
|
||||
|
||||
WRITE: / lv_date.
|
||||
1
Task/Show-the-epoch/ABAP/show-the-epoch-2.abap
Normal file
1
Task/Show-the-epoch/ABAP/show-the-epoch-2.abap
Normal file
|
|
@ -0,0 +1 @@
|
|||
cl_demo_output=>display( |Result: { CONV datum( 0 ) }| ).
|
||||
6
Task/Show-the-epoch/AWK/show-the-epoch.awk
Normal file
6
Task/Show-the-epoch/AWK/show-the-epoch.awk
Normal 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)
|
||||
}
|
||||
9
Task/Show-the-epoch/Ada/show-the-epoch.ada
Normal file
9
Task/Show-the-epoch/Ada/show-the-epoch.ada
Normal 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;
|
||||
15
Task/Show-the-epoch/AppleScript/show-the-epoch-1.applescript
Normal file
15
Task/Show-the-epoch/AppleScript/show-the-epoch-1.applescript
Normal 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
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
"Cocoa epoch: 2001-01-01 00:00:00 +0000
|
||||
Unix epoch: 1970-01-01 00:00:00 +0000"
|
||||
4
Task/Show-the-epoch/Arturo/show-the-epoch.arturo
Normal file
4
Task/Show-the-epoch/Arturo/show-the-epoch.arturo
Normal 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
|
||||
2
Task/Show-the-epoch/BBC-BASIC/show-the-epoch.basic
Normal file
2
Task/Show-the-epoch/BBC-BASIC/show-the-epoch.basic
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
INSTALL @lib$+"DATELIB"
|
||||
PRINT FN_date$(0, "dd-MMM-yyyy")
|
||||
10
Task/Show-the-epoch/C++/show-the-epoch-1.cpp
Normal file
10
Task/Show-the-epoch/C++/show-the-epoch-1.cpp
Normal 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;
|
||||
}
|
||||
7
Task/Show-the-epoch/C++/show-the-epoch-2.cpp
Normal file
7
Task/Show-the-epoch/C++/show-the-epoch-2.cpp
Normal 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;
|
||||
}
|
||||
9
Task/Show-the-epoch/C-sharp/show-the-epoch.cs
Normal file
9
Task/Show-the-epoch/C-sharp/show-the-epoch.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
using System;
|
||||
|
||||
class Program
|
||||
{
|
||||
static void Main()
|
||||
{
|
||||
Console.WriteLine(new DateTime());
|
||||
}
|
||||
}
|
||||
8
Task/Show-the-epoch/C/show-the-epoch-1.c
Normal file
8
Task/Show-the-epoch/C/show-the-epoch-1.c
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
time_t t = 0;
|
||||
printf("%s", asctime(gmtime(&t)));
|
||||
return 0;
|
||||
}
|
||||
34
Task/Show-the-epoch/C/show-the-epoch-2.c
Normal file
34
Task/Show-the-epoch/C/show-the-epoch-2.c
Normal 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;
|
||||
}
|
||||
17
Task/Show-the-epoch/COBOL/show-the-epoch.cobol
Normal file
17
Task/Show-the-epoch/COBOL/show-the-epoch.cobol
Normal 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
|
||||
.
|
||||
1
Task/Show-the-epoch/Clojure/show-the-epoch-1.clj
Normal file
1
Task/Show-the-epoch/Clojure/show-the-epoch-1.clj
Normal file
|
|
@ -0,0 +1 @@
|
|||
(println (java.util.Date. 0))
|
||||
1
Task/Show-the-epoch/Clojure/show-the-epoch-2.clj
Normal file
1
Task/Show-the-epoch/Clojure/show-the-epoch-2.clj
Normal file
|
|
@ -0,0 +1 @@
|
|||
#inst "1970-01-01T00:00:00.000-00:00"
|
||||
1
Task/Show-the-epoch/CoffeeScript/show-the-epoch.coffee
Normal file
1
Task/Show-the-epoch/CoffeeScript/show-the-epoch.coffee
Normal file
|
|
@ -0,0 +1 @@
|
|||
console.log new Date(0).toISOString()
|
||||
2
Task/Show-the-epoch/Common-Lisp/show-the-epoch.lisp
Normal file
2
Task/Show-the-epoch/Common-Lisp/show-the-epoch.lisp
Normal 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))
|
||||
3
Task/Show-the-epoch/Dart/show-the-epoch.dart
Normal file
3
Task/Show-the-epoch/Dart/show-the-epoch.dart
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
main() {
|
||||
print(new Date.fromEpoch(0,new TimeZone.utc()));
|
||||
}
|
||||
9
Task/Show-the-epoch/Delphi/show-the-epoch.delphi
Normal file
9
Task/Show-the-epoch/Delphi/show-the-epoch.delphi
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
program ShowEpoch;
|
||||
|
||||
{$APPTYPE CONSOLE}
|
||||
|
||||
uses SysUtils;
|
||||
|
||||
begin
|
||||
Writeln(FormatDateTime('yyyy-mm-dd hh:nn:ss.zzz', 0));
|
||||
end.
|
||||
1
Task/Show-the-epoch/F-Sharp/show-the-epoch.fs
Normal file
1
Task/Show-the-epoch/F-Sharp/show-the-epoch.fs
Normal file
|
|
@ -0,0 +1 @@
|
|||
printfn "%s" ((new System.DateTime()).ToString("u"))
|
||||
3
Task/Show-the-epoch/Factor/show-the-epoch.factor
Normal file
3
Task/Show-the-epoch/Factor/show-the-epoch.factor
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
USING: calendar calendar.format io ;
|
||||
|
||||
0 micros>timestamp timestamp>ymdhms print
|
||||
2
Task/Show-the-epoch/Forth/show-the-epoch.fth
Normal file
2
Task/Show-the-epoch/Forth/show-the-epoch.fth
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
include lib/longjday.4th
|
||||
0 posix>jday .longjday cr
|
||||
16
Task/Show-the-epoch/FreeBASIC/show-the-epoch.basic
Normal file
16
Task/Show-the-epoch/FreeBASIC/show-the-epoch.basic
Normal 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
|
||||
1
Task/Show-the-epoch/Frink/show-the-epoch-1.frink
Normal file
1
Task/Show-the-epoch/Frink/show-the-epoch-1.frink
Normal file
|
|
@ -0,0 +1 @@
|
|||
println[ JD[0 s] -> UTC ]
|
||||
2
Task/Show-the-epoch/Frink/show-the-epoch-2.frink
Normal file
2
Task/Show-the-epoch/Frink/show-the-epoch-2.frink
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
epoch = # 1970 UTC #
|
||||
now[] - epoch -> ns
|
||||
2
Task/Show-the-epoch/Frink/show-the-epoch-3.frink
Normal file
2
Task/Show-the-epoch/Frink/show-the-epoch-3.frink
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
epoch = # 1970 UTC #
|
||||
epoch + 2 billion seconds -> Japan
|
||||
17
Task/Show-the-epoch/FutureBasic/show-the-epoch.basic
Normal file
17
Task/Show-the-epoch/FutureBasic/show-the-epoch.basic
Normal 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
|
||||
6
Task/Show-the-epoch/Go/show-the-epoch.go
Normal file
6
Task/Show-the-epoch/Go/show-the-epoch.go
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
package main
|
||||
import ("fmt"; "time")
|
||||
|
||||
func main() {
|
||||
fmt.Println(time.Time{})
|
||||
}
|
||||
4
Task/Show-the-epoch/Groovy/show-the-epoch.groovy
Normal file
4
Task/Show-the-epoch/Groovy/show-the-epoch.groovy
Normal 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))
|
||||
3
Task/Show-the-epoch/Haskell/show-the-epoch-1.hs
Normal file
3
Task/Show-the-epoch/Haskell/show-the-epoch-1.hs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
import System.Time
|
||||
|
||||
main = putStrLn $ calendarTimeToString $ toUTCTime $ TOD 0 0
|
||||
3
Task/Show-the-epoch/Haskell/show-the-epoch-2.hs
Normal file
3
Task/Show-the-epoch/Haskell/show-the-epoch-2.hs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
import Data.Time
|
||||
|
||||
main = print $ UTCTime (ModifiedJulianDay 0) 0
|
||||
12
Task/Show-the-epoch/Icon/show-the-epoch.icon
Normal file
12
Task/Show-the-epoch/Icon/show-the-epoch.icon
Normal 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
|
||||
2
Task/Show-the-epoch/J/show-the-epoch-1.j
Normal file
2
Task/Show-the-epoch/J/show-the-epoch-1.j
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
6!:0''
|
||||
2011 8 8 20 25 44.725
|
||||
3
Task/Show-the-epoch/J/show-the-epoch-2.j
Normal file
3
Task/Show-the-epoch/J/show-the-epoch-2.j
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
require'dates'
|
||||
todate 0
|
||||
1800 1 1
|
||||
12
Task/Show-the-epoch/Java/show-the-epoch.java
Normal file
12
Task/Show-the-epoch/Java/show-the-epoch.java
Normal 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));
|
||||
}
|
||||
}
|
||||
1
Task/Show-the-epoch/JavaScript/show-the-epoch.js
Normal file
1
Task/Show-the-epoch/JavaScript/show-the-epoch.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
document.write(new Date(0).toUTCString());
|
||||
1
Task/Show-the-epoch/Jq/show-the-epoch-1.jq
Normal file
1
Task/Show-the-epoch/Jq/show-the-epoch-1.jq
Normal file
|
|
@ -0,0 +1 @@
|
|||
0 | todate
|
||||
1
Task/Show-the-epoch/Jq/show-the-epoch-2.jq
Normal file
1
Task/Show-the-epoch/Jq/show-the-epoch-2.jq
Normal file
|
|
@ -0,0 +1 @@
|
|||
"1970-01-01T00:00:00Z"
|
||||
2
Task/Show-the-epoch/Julia/show-the-epoch.julia
Normal file
2
Task/Show-the-epoch/Julia/show-the-epoch.julia
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
using Base.Dates # just using Dates in versions > 0.6
|
||||
println("Time zero (the epoch) is $(unix2datetime(0)).")
|
||||
12
Task/Show-the-epoch/Kotlin/show-the-epoch.kotlin
Normal file
12
Task/Show-the-epoch/Kotlin/show-the-epoch.kotlin
Normal 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))
|
||||
}
|
||||
2
Task/Show-the-epoch/Lasso/show-the-epoch.lasso
Normal file
2
Task/Show-the-epoch/Lasso/show-the-epoch.lasso
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
date(0.00)
|
||||
date(0)
|
||||
17
Task/Show-the-epoch/Limbo/show-the-epoch-1.limbo
Normal file
17
Task/Show-the-epoch/Limbo/show-the-epoch-1.limbo
Normal 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)));
|
||||
}
|
||||
34
Task/Show-the-epoch/Limbo/show-the-epoch-2.limbo
Normal file
34
Task/Show-the-epoch/Limbo/show-the-epoch-2.limbo
Normal 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())));
|
||||
}
|
||||
9
Task/Show-the-epoch/Lingo/show-the-epoch.lingo
Normal file
9
Task/Show-the-epoch/Lingo/show-the-epoch.lingo
Normal 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
|
||||
6
Task/Show-the-epoch/LiveCode/show-the-epoch.livecode
Normal file
6
Task/Show-the-epoch/LiveCode/show-the-epoch.livecode
Normal 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
|
||||
17
Task/Show-the-epoch/LotusScript/show-the-epoch.lotus
Normal file
17
Task/Show-the-epoch/LotusScript/show-the-epoch.lotus
Normal 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
|
||||
1
Task/Show-the-epoch/Lua/show-the-epoch.lua
Normal file
1
Task/Show-the-epoch/Lua/show-the-epoch.lua
Normal file
|
|
@ -0,0 +1 @@
|
|||
print(os.date("%c", 0))
|
||||
5
Task/Show-the-epoch/MATLAB/show-the-epoch.m
Normal file
5
Task/Show-the-epoch/MATLAB/show-the-epoch.m
Normal 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;
|
||||
1
Task/Show-the-epoch/Mathematica/show-the-epoch.math
Normal file
1
Task/Show-the-epoch/Mathematica/show-the-epoch.math
Normal file
|
|
@ -0,0 +1 @@
|
|||
DateString[0]
|
||||
2
Task/Show-the-epoch/Maxima/show-the-epoch.maxima
Normal file
2
Task/Show-the-epoch/Maxima/show-the-epoch.maxima
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
timedate(0);
|
||||
"1900-01-01 10:00:00+10:00"
|
||||
1
Task/Show-the-epoch/Min/show-the-epoch.min
Normal file
1
Task/Show-the-epoch/Min/show-the-epoch.min
Normal file
|
|
@ -0,0 +1 @@
|
|||
0 datetime puts!
|
||||
10
Task/Show-the-epoch/NetRexx/show-the-epoch.netrexx
Normal file
10
Task/Show-the-epoch/NetRexx/show-the-epoch.netrexx
Normal 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
|
||||
2
Task/Show-the-epoch/NewLISP/show-the-epoch.l
Normal file
2
Task/Show-the-epoch/NewLISP/show-the-epoch.l
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
(date 0)
|
||||
->"Thu Jan 01 01:00:00 1970"
|
||||
4
Task/Show-the-epoch/Nim/show-the-epoch.nim
Normal file
4
Task/Show-the-epoch/Nim/show-the-epoch.nim
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
import times
|
||||
|
||||
echo "Epoch for Posix systems: ", fromUnix(0).utc
|
||||
echo "Epoch for Windows system: ", fromWinTime(0).utc
|
||||
8
Task/Show-the-epoch/OCaml/show-the-epoch.ocaml
Normal file
8
Task/Show-the-epoch/OCaml/show-the-epoch.ocaml
Normal 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)
|
||||
14
Task/Show-the-epoch/Objective-C/show-the-epoch.m
Normal file
14
Task/Show-the-epoch/Objective-C/show-the-epoch.m
Normal 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;
|
||||
}
|
||||
3
Task/Show-the-epoch/Oforth/show-the-epoch.fth
Normal file
3
Task/Show-the-epoch/Oforth/show-the-epoch.fth
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
import: date
|
||||
|
||||
0 asDateUTC println
|
||||
1
Task/Show-the-epoch/PARI-GP/show-the-epoch.parigp
Normal file
1
Task/Show-the-epoch/PARI-GP/show-the-epoch.parigp
Normal file
|
|
@ -0,0 +1 @@
|
|||
system("date -ur 0")
|
||||
3
Task/Show-the-epoch/PHP/show-the-epoch.php
Normal file
3
Task/Show-the-epoch/PHP/show-the-epoch.php
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<?php
|
||||
echo gmdate('r', 0), "\n";
|
||||
?>
|
||||
17
Task/Show-the-epoch/PL-I/show-the-epoch.pli
Normal file
17
Task/Show-the-epoch/PL-I/show-the-epoch.pli
Normal 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;
|
||||
9
Task/Show-the-epoch/Pascal/show-the-epoch.pas
Normal file
9
Task/Show-the-epoch/Pascal/show-the-epoch.pas
Normal 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.
|
||||
1
Task/Show-the-epoch/Perl/show-the-epoch.pl
Normal file
1
Task/Show-the-epoch/Perl/show-the-epoch.pl
Normal file
|
|
@ -0,0 +1 @@
|
|||
print scalar gmtime 0, "\n";
|
||||
7
Task/Show-the-epoch/Phix/show-the-epoch.phix
Normal file
7
Task/Show-the-epoch/Phix/show-the-epoch.phix
Normal 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>
|
||||
<!--
|
||||
2
Task/Show-the-epoch/PicoLisp/show-the-epoch.l
Normal file
2
Task/Show-the-epoch/PicoLisp/show-the-epoch.l
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
: (date 1)
|
||||
-> (0 3 1) # Year zero, March 1st
|
||||
2
Task/Show-the-epoch/Pike/show-the-epoch.pike
Normal file
2
Task/Show-the-epoch/Pike/show-the-epoch.pike
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
object cal = Calendar.ISO->set_timezone("UTC");
|
||||
write( cal.Second(0)->format_iso_short() );
|
||||
1
Task/Show-the-epoch/PowerShell/show-the-epoch-1.psh
Normal file
1
Task/Show-the-epoch/PowerShell/show-the-epoch-1.psh
Normal file
|
|
@ -0,0 +1 @@
|
|||
[datetime] 0
|
||||
1
Task/Show-the-epoch/PowerShell/show-the-epoch-2.psh
Normal file
1
Task/Show-the-epoch/PowerShell/show-the-epoch-2.psh
Normal file
|
|
@ -0,0 +1 @@
|
|||
Get-Date -Year 1 -Month 1 -Day 1 -Hour 0 -Minute 0 -Second 0 -Millisecond 0
|
||||
1
Task/Show-the-epoch/PowerShell/show-the-epoch-3.psh
Normal file
1
Task/Show-the-epoch/PowerShell/show-the-epoch-3.psh
Normal file
|
|
@ -0,0 +1 @@
|
|||
New-Object -TypeName System.DateTime
|
||||
1
Task/Show-the-epoch/PowerShell/show-the-epoch-4.psh
Normal file
1
Task/Show-the-epoch/PowerShell/show-the-epoch-4.psh
Normal file
|
|
@ -0,0 +1 @@
|
|||
New-Object -TypeName System.DateTime -ArgumentList 1, 1, 1, 0, 0, 0, ([DateTimeKind]::Utc) | Format-List
|
||||
6
Task/Show-the-epoch/PureBasic/show-the-epoch.basic
Normal file
6
Task/Show-the-epoch/PureBasic/show-the-epoch.basic
Normal 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
|
||||
4
Task/Show-the-epoch/Python/show-the-epoch.py
Normal file
4
Task/Show-the-epoch/Python/show-the-epoch.py
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
>>> import time
|
||||
>>> time.asctime(time.gmtime(0))
|
||||
'Thu Jan 1 00:00:00 1970'
|
||||
>>>
|
||||
4
Task/Show-the-epoch/R/show-the-epoch.r
Normal file
4
Task/Show-the-epoch/R/show-the-epoch.r
Normal 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"
|
||||
11
Task/Show-the-epoch/REXX/show-the-epoch.rexx
Normal file
11
Task/Show-the-epoch/REXX/show-the-epoch.rexx
Normal 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. */
|
||||
3
Task/Show-the-epoch/Racket/show-the-epoch.rkt
Normal file
3
Task/Show-the-epoch/Racket/show-the-epoch.rkt
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
#lang racket
|
||||
(require racket/date)
|
||||
(date->string (seconds->date 0 #f))
|
||||
1
Task/Show-the-epoch/Raku/show-the-epoch.raku
Normal file
1
Task/Show-the-epoch/Raku/show-the-epoch.raku
Normal file
|
|
@ -0,0 +1 @@
|
|||
say DateTime.new(0)
|
||||
14
Task/Show-the-epoch/Ring/show-the-epoch.ring
Normal file
14
Task/Show-the-epoch/Ring/show-the-epoch.ring
Normal 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()
|
||||
}
|
||||
2
Task/Show-the-epoch/Ruby/show-the-epoch-1.rb
Normal file
2
Task/Show-the-epoch/Ruby/show-the-epoch-1.rb
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
irb(main):001:0> Time.at(0).utc
|
||||
=> 1970-01-01 00:00:00 UTC
|
||||
2
Task/Show-the-epoch/Ruby/show-the-epoch-2.rb
Normal file
2
Task/Show-the-epoch/Ruby/show-the-epoch-2.rb
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
require "date"
|
||||
Date.new # => #<Date: -4712-01-01 ((0j,0s,0n),+0s,2299161j)>
|
||||
3
Task/Show-the-epoch/Run-BASIC/show-the-epoch.basic
Normal file
3
Task/Show-the-epoch/Run-BASIC/show-the-epoch.basic
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
eDate$ = date$("01/01/0001")
|
||||
cDate$ = date$(0) ' 01/01/1901
|
||||
sDate$ = date$("01/01/1970")
|
||||
8
Task/Show-the-epoch/Rust/show-the-epoch.rust
Normal file
8
Task/Show-the-epoch/Rust/show-the-epoch.rust
Normal 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());
|
||||
}
|
||||
6
Task/Show-the-epoch/Scala/show-the-epoch.scala
Normal file
6
Task/Show-the-epoch/Scala/show-the-epoch.scala
Normal 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)))
|
||||
2
Task/Show-the-epoch/Scheme/show-the-epoch.ss
Normal file
2
Task/Show-the-epoch/Scheme/show-the-epoch.ss
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
; Display date at Time Zero in UTC.
|
||||
(printf "~s~%" (time-utc->date (make-time 'time-utc 0 0) 0))
|
||||
7
Task/Show-the-epoch/Seed7/show-the-epoch.seed7
Normal file
7
Task/Show-the-epoch/Seed7/show-the-epoch.seed7
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
$ include "seed7_05.s7i";
|
||||
include "time.s7i";
|
||||
|
||||
const proc: main is func
|
||||
begin
|
||||
writeln(time.value);
|
||||
end func;
|
||||
1
Task/Show-the-epoch/Sidef/show-the-epoch.sidef
Normal file
1
Task/Show-the-epoch/Sidef/show-the-epoch.sidef
Normal file
|
|
@ -0,0 +1 @@
|
|||
say Time.new(0).gmtime.ctime;
|
||||
2
Task/Show-the-epoch/Standard-ML/show-the-epoch.ml
Normal file
2
Task/Show-the-epoch/Standard-ML/show-the-epoch.ml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
- Date.toString (Date.fromTimeUniv Time.zeroTime);
|
||||
val it = "Thu Jan 1 00:00:00 1970" : string
|
||||
4
Task/Show-the-epoch/Stata/show-the-epoch.stata
Normal file
4
Task/Show-the-epoch/Stata/show-the-epoch.stata
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
. di %td 0
|
||||
01jan1960
|
||||
. di %tc 0
|
||||
01jan1960 00:00:00
|
||||
10
Task/Show-the-epoch/TUSCRIPT/show-the-epoch.tu
Normal file
10
Task/Show-the-epoch/TUSCRIPT/show-the-epoch.tu
Normal 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,")"
|
||||
2
Task/Show-the-epoch/Tcl/show-the-epoch.tcl
Normal file
2
Task/Show-the-epoch/Tcl/show-the-epoch.tcl
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
% clock format 0 -gmt 1
|
||||
Thu Jan 01 00:00:00 GMT 1970
|
||||
2
Task/Show-the-epoch/UNIX-Shell/show-the-epoch-1.sh
Normal file
2
Task/Show-the-epoch/UNIX-Shell/show-the-epoch-1.sh
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
$ date -ur 0
|
||||
Thu Jan 1 00:00:00 UTC 1970
|
||||
2
Task/Show-the-epoch/UNIX-Shell/show-the-epoch-2.sh
Normal file
2
Task/Show-the-epoch/UNIX-Shell/show-the-epoch-2.sh
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
$ TZ=UTC date --date "$(date +%s) seconds ago"
|
||||
Thu Jan 1 00:00:00 UTC 1970
|
||||
3
Task/Show-the-epoch/Visual-Basic/show-the-epoch.vb
Normal file
3
Task/Show-the-epoch/Visual-Basic/show-the-epoch.vb
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
Sub Main()
|
||||
Debug.Print Format(0, "dd mmm yyyy hh:mm")
|
||||
End Sub
|
||||
8
Task/Show-the-epoch/Wren/show-the-epoch.wren
Normal file
8
Task/Show-the-epoch/Wren/show-the-epoch.wren
Normal 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)
|
||||
2
Task/Show-the-epoch/Zkl/show-the-epoch.zkl
Normal file
2
Task/Show-the-epoch/Zkl/show-the-epoch.zkl
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
zkl: Time.Clock.tickToTock(0,False)
|
||||
L(1970,1,1,0,0,0) // y,m,d, h,m,s
|
||||
Loading…
Add table
Add a link
Reference in a new issue