DateTime hex format decipher - date

I am working on a little puzzle. I have some timestamps that I know they are timestamps but can't figure out how they are encoded.
3ebf5b89 means 08-October-2013 hour 8 AM but minute I can't provide neither second
3ebd5f09 means 09-October-2013 hour 8 AM Unknown minute/second.
3ea15d09 means 11-October-2013 hour 8 AM Unknown minute/second but before half past hour.
Any ideas on the encoding?
The weird part is that the dates seem to become lower values as days pass.
If I convert to decimal and substract the big date from the small date I get a value witch converted in seconds is around the days between two dates with a 5 hour error per day.
LE:
I managed to get more accurate time stamps :
3ea02d09 - Oct 11th, 2013 at 17:10 (hour:minute)
3ea7ff89 - Oct 12th, 2013 at 14:28
3ea7cf09 - Oct 12th, 2013 at 15:34

it seemed that the timestamp uses Pi as its base to calculate the time!?
3ea7ff89 - 12 October Hour 14 Minute 28
3ea7cf09 - 12 October Hour 15 Minute 34
difference: 12416 ~ 66 minutes
if we divide it by 60 for 60 seconds per minute an after that we divide it by 66 for the minutes difference we get
3.13535353535 that is realy close to Pi.
if we use pi to reverse the formular:
Pi*66*60=12440 thats in the error range of the not delivered seconds in your timestamps.

I wonder those HEX converted to Decimal has some relation to Unix Epoch time :
Those Hex numbers are translating to some valid Dates though different from what you mentioned those are :
Hex 3ebf5b89 = Decimal 1052728201 = Mon, 12 May 2003 08:30:01 GMT
Hex 3ebd5f09 = Decimal 1052598025 = Sat, 10 May 2003 20:20:25 GMT
Hex 3ea15d09 = Decimal 1050762505 = Sat, 19 Apr 2003 14:28:25 GMT
Hex 3ea02d09 = Decimal 1050684681 = Fri, 18 Apr 2003 16:51:21 GMT
Hex 3ea7ff89 = Decimal 1051197321 = Thu, 24 Apr 2003 15:15:21 GMT
Hex 3ea7cf09 = Decimal 1051184905 = Thu, 24 Apr 2003 11:48:25 GMT

I've tried to play around with the binary form of your inputs and using the bitwise XOR (the poor man's cipher) operator between the value and the corresponding UNIX timestamp.
This is what I've got so far:
(1381507800 ^ 0x3ea02d09) = 0110110011111 00000001111 11 010 001
(1381584480 ^ 0x3ea7ff89) = 0110110011111 11010110001 11 101 001
(1381588440 ^ 0x3ea7cf09) = 0110110011111 11010010010 11 010 001
16bits + 2bits stay stable.
The first 13bits plus the last 3bits (which make 16bits if combined) make me think of some kind of rotate shift left.
Please note that my timezone is UTC+1 and thus my UNIX time stamps may not be exact. It would be great if you can get the corresponding timestamps on your system to push this lead further.

Related

looking for spark scala(java) code for date string with spaces in between with specific conditions

need some suggestions on below requirement.
Each response help a lot thanks in advance....
I have a date of type String with timestamp ex: Jan 8 2019 4:44 AM
My requirement is if the date is single digit I want date to be 1 space and digit
(ex: 8) and if the date is 2 digits which is dates from 10 to 31 I want date with no space(ex:10) and also same for hour in timestamp.
to summarize: if the date is 1 to 9 and hour in timestamp is 1 to 9 looking for below string
Jan 8 2019 4:44 AM
if the date is 10 to 31 and hour in timestamp is 10 to 12 looking for below string
Jan 18 2019 12:44 AM
right now I am creating a date in following way:
val sdf = new SimpleDateFormat("MMM d yyyy h:mm a")
but the above format satisfies only one condition which is dates from 1 to 9.
my application is spark with scala so looking for some spark scala code or java.
I appreciate your help...
Thanks..
java.time
Use p as a pad modifier in the format pattern string. In Java syntax (sorry):
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(
"MMM ppd ppppu pph:mm a", Locale.ENGLISH);
System.out.println(LocalDateTime.of(2019, Month.JANUARY, 8, 4, 44)
.format(formatter));
System.out.println(LocalDateTime.of(2019, Month.JANUARY, 18, 0, 44)
.format(formatter));
Jan 8 2019 4:44 AM
Jan 18 2019 12:44 AM
And do yourself the favour: Forget everything about the SimpleDateFormat class. It is notoriously troublesome and fortunately long outdated. Use java.time, the modern Java date and time API.
Link: Oracle tutorial: Date Time explaining how to use java.time.
To quote the DateTimeFormatter class documentation:
Pad modifier: Modifies the pattern that immediately follows to be padded with spaces. The pad width is determined by the number of pattern letters. This is the same as calling DateTimeFormatterBuilder.padNext(int).
For example, 'ppH' outputs the hour-of-day padded on the left with spaces to a width of 2.

Sort string + date by most current date in Perl

I have an array:
my #array = ( "\"Passing\" on Wed 12 Jan 2015 09:19:14 AM PST",
"\"Passing\" on Wed 12 Jan 2015 09:19:25 AM PST",
"\"Test Activation\" on Tues 14 Jan 2015 12:05:14 PM PST",
"\"Run Phase\" on Tues 14 Jan 2015 12:06:14 PM PST",
"\"Test Activation\" on Tues 13 Jan 2015 11:43:12 PM PST")
I want to remove the duplicate string line BUT keep the one that is most recent. So I want it to look like:
my #array = ("\"Passing\" on Wed 12 Jan 2015 09:19:25 AM PST",
"\"Test Activation\" on Tues 14 Jan 2015 12:05:14 PM PST",
"\"Run Phase\" on Tues 14 Jan 2015 12:06:14 PM PST")
I can't think of an easy way to do this... I was thinking about using some regex to compare the strings ( /\".*\"/ ) and have it remove duplicates it finds, but I'm not sure how to deal with the date/time.
Any suggestions are most welcome!
There's several options to parse and compare the dates. Simplest is to use the built in Time::Piece. Use strptime for parsing and compare with $time->epoch.
Unfortunately for you, abbreviated time zone names are ambiguous. PST can mean US Pacific Standard Time or Philippine Standard Time. This may cause strptime's %Z format to choke, YMMV. From my strptime man page...
The %Z format specifier only accepts time zone abbreviations of the local time zone, or the value "GMT". This limitation is because of ambiguity due to of the over loading of time zone abbreviations. One such example is EST which is both Eastern Standard Time and Eastern Australia Summer Time.
You may need to pre-process the date formats and convert them to time zone offsets. You can use Time::Zone for this and its distinctly North American slant.
use Time::Zone;
use Time::Piece;
my $offset = sprintf "%+d", (tz_offset("PST") / 60 / 60);
my $time = Time::Piece->strptime(
"Wed 12 Jan 2015 09:19:14 AM $offset",
"%a %d %b %Y %I:%M:%S %p %z"
);
print $time->datetime, "\n";
print $time->epoch, "\n";
But try %Z first and see if it works.
Extracting the dates is also left as an exercise.

Date value as float - Apple's iWork Numbers 09 - internal XML

I am writing a script in PHP which will convert Numbers file into HTML table, but I can not figure out which format is used for date storage. The date cell tag looks like
<sf:d
sf:s="SFTCellStyle-128"
sf:w="84.074219"
sf:h="14"
sf:cell-date="371397519.99999952" />
so the date must be in sf:cell-date attribute, but I can not figure out how to convert it into human readable format. Any ideas? I have never seen date value as float number.
As written in a comment, it is the number of seconds since 01/01/2001 at 00:00:00. Equipped with that knowledge and because this goes hand in hand with the UNIX Epoch all you need to do is to define and use the offset. It should be compatible with nearly every of the existing PHP date functions and objects, for example with date:
define('CELL_DATE_EPOCH_OFFSET', 978307200);
$sf_cell_date = 371397519.99999952;
echo date('r', CELL_DATE_EPOCH_OFFSET + $sf_cell_date);
The output of this little script is (in my timezone):
Mon, 08 Oct 2012 15:58:39 +0200
I hope this is helpful. 978307200 is the unix timestamp for 01/01/2001 00:00:00 UTC, you can get with PHP for example with the following code-example:
$base = new DateTime('01/01/2001 00:00:00 UTC');
echo $base->getTimestamp(), "\n";
in case that was your problem.

PHP4: Adjust date() and strtotime() for different timezones

I'm working on a podcast (on-the-road events) that contains future dates and different time zones.
<pubDate>Wed, 14 Nov 2012 19:00:00 EST</pubDate>
<pubDate>Wed, 25 Jul 2012 19:00:00 CDT</pubDate>
<pubDate>Thu, 29 Mar 2012 19:00:00 MDT</pubDate>
When I parse it with PHP4 (note PHP4), using date() and strtotime(), it adjusts the information and outputs it in the current timezone of the server (including daylight saving time changes).
Code...
date("g:ia T", strtotime($item->pubDate));
Example...
<pubDate>Thu, 29 Mar 2012 19:00:00 MDT</pubDate> outputs 8:00pm CDT
The expected output is 7:00pm MDT
Again, I'm using PHP4, so I can't do DateTime()-type stuff.
Basically, I just want it to just return the characters, instead of interpreting the characters. Maybe I shouldn't use date() or strtotime() at all, but I'm not sure of another way to turn Wed into Wednesday, 19:00:00 into 7:00pm, etc.

Convert seconds to date from Jan 01 1901 in unix/linux

im trying to convert a time stamp in seconds from Jan 01 1901 to the current date.
for example,
time stamp 3465468225 translate to a date in 2010. does anyone know of a way to do this in unix/linux? thanks.
In R, it is as simple as this:
> as.POSIXct(3465468225, origin="1901-01-01")
[1] "2010-10-25 15:03:45 CDT"
>
This uses appropriate wrappers around C-level calls gmtime() / localtime() plus time formatting via strftime().
On GNU and POSIX systems you can obtain the date string using seconds since Epoch (1970-01-01 00:00:00 UTC) as:
$ date --date=#1289495920
Thu Nov 11 12:18:40 EST 2010
You should handle the offset since Jan 01 1901 yourself.