September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
4
Task/Date-format/BaCon/date-format.bacon
Normal file
4
Task/Date-format/BaCon/date-format.bacon
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
' Date format
|
||||
n = NOW
|
||||
PRINT YEAR(n), MONTH(n), DAY(n) FORMAT "%ld-%02ld-%02ld\n"
|
||||
PRINT WEEKDAY$(n), MONTH$(n), DAY(n), YEAR(n) FORMAT "%s, %s %02ld, %ld\n"
|
||||
35
Task/Date-format/Batch-File/date-format.bat
Normal file
35
Task/Date-format/Batch-File/date-format.bat
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
@echo off
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
:: Define arrays of days/months we'll need
|
||||
set daynames=Monday Tuesday Wednesday Thursday Friday Saturday Sunday
|
||||
set monthnames=January February March April May June July August September October November December
|
||||
|
||||
:: Separate the output of the 'date /t' command (outputs in the format of "Sun 16/04/2017") into 4 variables
|
||||
for /f "tokens=1,2,3,4 delims=/ " %%i in ('date /t') do (
|
||||
set dayname=%%i
|
||||
set day=%%j
|
||||
set month=%%k
|
||||
set year=%%l
|
||||
)
|
||||
|
||||
:: Crosscheck the first 3 letters of every word in %daynames% to the 3 letter day name found previously
|
||||
for %%i in (%daynames%) do (
|
||||
set tempdayname=%%i
|
||||
set comparedayname=!tempdayname:~0,3!
|
||||
if "%dayname%"=="!comparedayname!" set fulldayname=%%i
|
||||
)
|
||||
|
||||
:: Variables starting with "0" during the 'set /a' command are treated as octal numbers. To avoid this, if the first character of %month% is "0", it is removed
|
||||
if "%month:~0,1%"=="0" set monthtemp=%month:~1,1%
|
||||
set monthcount=0
|
||||
|
||||
:: Iterates through %monthnames% and when it reaches the amount of iterations dictated by %month%, sets %monthname% as the current month being iterated through
|
||||
for %%i in (%monthnames%) do (
|
||||
set /a monthcount+=1
|
||||
if %monthtemp%==!monthcount! set monthname=%%i
|
||||
)
|
||||
|
||||
echo %year%-%month%-%day%
|
||||
echo %fulldayname%, %monthname% %day%, %year%
|
||||
pause>nul
|
||||
|
|
@ -1,25 +1,23 @@
|
|||
defmodule Date do
|
||||
def iso_date, do: iso_date(:erlang.date)
|
||||
defmodule Date_format do
|
||||
def iso_date, do: Date.utc_today |> Date.to_iso8601
|
||||
|
||||
def iso_date(year, month, day), do: iso_date({year, month, day})
|
||||
def iso_date(year, month, day), do: Date.from_erl!({year, month, day}) |> Date.to_iso8601
|
||||
|
||||
def iso_date(date), do:
|
||||
:io.format("~4b-~2..0B-~2..0B~n", Tuple.to_list(date))
|
||||
def long_date, do: Date.utc_today |> long_date
|
||||
|
||||
def long_date, do: long_date(:erlang.date)
|
||||
def long_date(year, month, day), do: Date.from_erl!({year, month, day}) |> long_date
|
||||
|
||||
def long_date(year, month, day), do: long_date({year, month, day})
|
||||
|
||||
def long_date(date = {year, month, day}) do
|
||||
months = { "January", "February", "March", "April", "May", "June",
|
||||
"July", "August", "September", "October", "November", "December" }
|
||||
weekdays = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" }
|
||||
weekday = :calendar.day_of_the_week(date)
|
||||
IO.puts "#{elem(weekdays, weekday-1)}, #{elem(months, month-1)} #{day}, #{year}"
|
||||
@months Enum.zip(1..12, ~w[January February March April May June July August September October November December])
|
||||
|> Map.new
|
||||
@weekdays Enum.zip(1..7, ~w[Monday Tuesday Wednesday Thursday Friday Saturday Sunday])
|
||||
|> Map.new
|
||||
def long_date(date) do
|
||||
weekday = Date.day_of_week(date)
|
||||
"#{@weekdays[weekday]}, #{@months[date.month]} #{date.day}, #{date.year}"
|
||||
end
|
||||
end
|
||||
|
||||
Date.iso_date
|
||||
Date.iso_date(2007,11,10)
|
||||
Date.long_date
|
||||
Date.long_date(2007,11,10)
|
||||
IO.puts Date_format.iso_date
|
||||
IO.puts Date_format.long_date
|
||||
IO.puts Date_format.iso_date(2007,11,10)
|
||||
IO.puts Date_format.long_date(2007,11,10)
|
||||
|
|
|
|||
6
Task/Date-format/Gambas/date-format.gambas
Normal file
6
Task/Date-format/Gambas/date-format.gambas
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
Public Sub Main()
|
||||
|
||||
Print Format(Now, "yyyy - mm - dd")
|
||||
Print Format(Now, "dddd, mmmm dd, yyyy")
|
||||
|
||||
End
|
||||
|
|
@ -1,13 +1,11 @@
|
|||
import Control.Monad
|
||||
import Data.Time
|
||||
import System.Locale
|
||||
(FormatTime, formatTime, defaultTimeLocale, utcToLocalTime,
|
||||
getCurrentTimeZone, getCurrentTime)
|
||||
|
||||
format1 :: FormatTime t => t -> String
|
||||
format1 = formatTime defaultTimeLocale "%Y-%m-%e"
|
||||
|
||||
format2 :: FormatTime t => t -> String
|
||||
format2 = formatTime defaultTimeLocale "%A, %B %d, %Y"
|
||||
formats :: FormatTime t => [t -> String]
|
||||
formats = (formatTime defaultTimeLocale) <$> ["%F", "%A, %B %d, %Y"]
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
t <- liftM2 utcToLocalTime getCurrentTimeZone getCurrentTime
|
||||
mapM_ putStrLn [format1 t, format2 t]
|
||||
t <- pure utcToLocalTime <*> getCurrentTimeZone <*> getCurrentTime
|
||||
putStrLn $ unlines (formats <*> pure t)
|
||||
|
|
|
|||
9
Task/Date-format/Kotlin/date-format.kotlin
Normal file
9
Task/Date-format/Kotlin/date-format.kotlin
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
// version 1.0.6
|
||||
|
||||
import java.util.GregorianCalendar
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val now = GregorianCalendar()
|
||||
println("%tF".format(now))
|
||||
println("%tA, %1\$tB %1\$te, %1\$tY".format(now))
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
echo -ag $time(yyyy-mm-dd)
|
||||
echo -ag $time(dddd $+ $chr(44) mmmm dd $+ $chr(44) yyyy)
|
||||
3
Task/Date-format/Maple/date-format.maple
Normal file
3
Task/Date-format/Maple/date-format.maple
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
with(StringTools);
|
||||
FormatTime("%Y-%m-%d")
|
||||
FormatTime("%A,%B %d, %y")
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
import times
|
||||
|
||||
var t = getTime().getLocalTime()
|
||||
echo(t.format("yyyy-MM-dd"))
|
||||
echo(t.format("dddd',' MMMM d',' yyyy"))
|
||||
3
Task/Date-format/SQL/date-format.sql
Normal file
3
Task/Date-format/SQL/date-format.sql
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
select to_char(sysdate,'YYYY-MM-DD') date_fmt_1 from dual;
|
||||
|
||||
select to_char(sysdate,'fmDay, Month DD, YYYY') date_fmt_2 from dual;
|
||||
16
Task/Date-format/Scheme/date-format.ss
Normal file
16
Task/Date-format/Scheme/date-format.ss
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
(define short-date
|
||||
(lambda (lt)
|
||||
(strftime "%Y-%m-%d" (localtime lt))))
|
||||
|
||||
(define long-date
|
||||
(lambda (lt)
|
||||
(strftime "%A, %B %d, %Y" (localtime lt))))
|
||||
|
||||
(define main
|
||||
(lambda (args)
|
||||
;; Current date
|
||||
(let ((dt (car (gettimeofday))))
|
||||
;; Short style
|
||||
(display (short-date dt))(newline)
|
||||
;; Long style
|
||||
(display (long-date dt))(newline))))
|
||||
2
Task/Date-format/Stata/date-format.stata
Normal file
2
Task/Date-format/Stata/date-format.stata
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
display %tdCCYY-NN-DD td($S_DATE)
|
||||
display %tdDayname,_Month_dd,_CCYY td($S_DATE)
|
||||
2
Task/Date-format/Zkl/date-format-1.zkl
Normal file
2
Task/Date-format/Zkl/date-format-1.zkl
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
"%d-%02d-%02d".fmt(Time.Clock.localTime.xplode()).println()
|
||||
//--> "2014-02-28" (ISO format)
|
||||
2
Task/Date-format/Zkl/date-format-2.zkl
Normal file
2
Task/Date-format/Zkl/date-format-2.zkl
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
Time.Date.prettyDay(Time.Clock.localTime.xplode())
|
||||
//--> "Friday, the 28th of February 2014"
|
||||
4
Task/Date-format/Zkl/date-format-3.zkl
Normal file
4
Task/Date-format/Zkl/date-format-3.zkl
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
y,m,d:=Time.Clock.localTime; D:=Time.Date;
|
||||
"%s, %s %d, %d".fmt(D.dayName(D.weekDay(y,m,d)),
|
||||
D.monthName(m), d,y)
|
||||
//-->"Friday, February 28, 2014"
|
||||
Loading…
Add table
Add a link
Reference in a new issue