Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

added some date formats #1

Merged
merged 2 commits into from

2 participants

@jchris

these are the basic ones that tend to get saved by JavaScript

now all I gotta go is figure out how to get your module into a map-reduce ...

@daleharvey daleharvey referenced this pull request from a commit
@daleharvey Merged pull request #1 from jchris/master.
added some date formats
3524685
@daleharvey daleharvey merged commit 3524685 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 24, 2011
  1. @jchris
  2. @jchris

    parse another json time I found

    jchris authored
This page is out of date. Refresh to see the latest.
Showing with 30 additions and 0 deletions.
  1. +30 −0 dh_date.erl
View
30 dh_date.erl
@@ -112,6 +112,19 @@ parse([Day,Month,Year,Hour,$:,Min,$:,Sec | PAM], _Now, _Opts)
when ?is_meridian(PAM) ->
{{Year, Month, Day}, {hour(Hour, PAM), Min, Sec}};
+%% Mon Oct 30 20:12:06 +0000 2006
+parse([Month, Day, Hour, $:, Min, $:, Sec, _, 0, Year], _Now, _Opts) ->
+ {{Year, Month, Day}, {Hour, Min, Sec}};
+%% Mon, 12 Sep 2006 19:36:04 +0000
+parse([_C, Day, Month, Year, Hour, $:, Min, $:, Sec, _, 0], _Now, _Opts) ->
+ {{Year, Month, Day}, {Hour, Min, Sec}};
+
+%% 2010-09-01T20:49:05
+parse([Year, $-, Month, $-, Day, {bad_token,84}, Hour, $:, Min, $:, Sec], _Now, _Opts) ->
+ {{Year, Month, Day}, {Hour, Min, Sec}};
+%% 2010-09-01T20:49:05.185Z
+parse([Year, $-, Month, $-, Day, {bad_token,84}, Hour, $:, Min, $:, Sec | _Rest], _Now, _Opts) ->
+ {{Year, Month, Day}, {Hour, Min, Sec}};
parse(_Tokens, _Now, _Opts) ->
{error, bad_date}.
@@ -153,6 +166,23 @@ tokenise("NOV"++Rest, Acc) -> tokenise(Rest, [11 | Acc]);
tokenise("DECEMBER"++Rest, Acc) -> tokenise(Rest, [12 | Acc]);
tokenise("DEC"++Rest, Acc) -> tokenise(Rest, [12 | Acc]);
+
+tokenise("MONDAY"++Rest, Acc) -> tokenise(Rest, Acc);
+tokenise("MON"++Rest, Acc) -> tokenise(Rest, Acc);
+tokenise("TUESDAY"++Rest, Acc) -> tokenise(Rest, Acc);
+tokenise("TUE"++Rest, Acc) -> tokenise(Rest, Acc);
+tokenise("WEDNESDAY"++Rest, Acc) -> tokenise(Rest, Acc);
+tokenise("WED"++Rest, Acc) -> tokenise(Rest, Acc);
+tokenise("THURSDAY"++Rest, Acc) -> tokenise(Rest, Acc);
+tokenise("THU"++Rest, Acc) -> tokenise(Rest, Acc);
+tokenise("FRIDAY"++Rest, Acc) -> tokenise(Rest, Acc);
+tokenise("FRI"++Rest, Acc) -> tokenise(Rest, Acc);
+tokenise("SATURDAY"++Rest, Acc) -> tokenise(Rest, Acc);
+tokenise("SAT"++Rest, Acc) -> tokenise(Rest, Acc);
+tokenise("SUNDAY"++Rest, Acc) -> tokenise(Rest, Acc);
+tokenise("SUN"++Rest, Acc) -> tokenise(Rest, Acc);
+
+
tokenise([$: | Rest], Acc) -> tokenise(Rest, [ $: | Acc]);
tokenise([$/ | Rest], Acc) -> tokenise(Rest, [ $/ | Acc]);
tokenise([$- | Rest], Acc) -> tokenise(Rest, [ $- | Acc]);
Something went wrong with that request. Please try again.