Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > “Stardate” Version Numbering

Reply
Thread Tools

“Stardate” Version Numbering

 
 
Lawrence D'Oliveiro
Guest
Posts: n/a
 
      06-07-2011
The following one-liner sets the versionName attribute in
AndroidManifest.xml to a number based on the number of days (accurate to
0.1 day) since the *nix epoch. This is what I’ve been using for a
version number in one or two projects, in lieu of anything that makes
more sense.

sed -i -r 's/(android:versionName=\")[^\"]*(\")/\1'"$(bc <<<"scale = 1; ($(Julian -f) - $(Julian -d 1970 1 1)) / 1")"'\2/' AndroidManifest.xml

This needs my “Julian” script, available here
<https://github.com/ldo/Julian>. Though it can probably be rewritten
to do without it, using the GNU “date” command instead...
 
Reply With Quote
 
 
 
 
Silvio
Guest
Posts: n/a
 
      06-07-2011
On 06/07/2011 01:59 PM, Lawrence D'Oliveiro wrote:
> The following one-liner sets the versionName attribute in
> AndroidManifest.xml to a number based on the number of days (accurate to
> 0.1 day) since the *nix epoch. This is what I’ve been using for a
> version number in one or two projects, in lieu of anything that makes
> more sense.
>
> sed -i -r 's/(android:versionName=\")[^\"]*(\")/\1'"$(bc<<<"scale = 1; ($(Julian -f) - $(Julian -d 1970 1 1)) / 1")"'\2/' AndroidManifest.xml
>
> This needs my “Julian” script, available here
> <https://github.com/ldo/Julian>. Though it can probably be rewritten
> to do without it, using the GNU “date” command instead...


What about date +%s%N

 
Reply With Quote
 
 
 
 
Daniele Futtorovic
Guest
Posts: n/a
 
      06-07-2011
On 07/06/2011 13:59, Lawrence D'Oliveiro allegedly wrote:
> The following one-liner sets the versionName attribute in
> AndroidManifest.xml to a number based on the number of days (accurate to
> 0.1 day) since the *nix epoch. This is what Ive been using for a
> version number in one or two projects, in lieu of anything that makes
> more sense.
>
> sed -i -r 's/(android:versionName=\")[^\"]*(\")/\1'"$(bc <<<"scale = 1; ($(Julian -f) - $(Julian -d 1970 1 1)) / 1")"'\2/' AndroidManifest.xml
>
> This needs my Julian script, available here
> <https://github.com/ldo/Julian>. Though it can probably be rewritten
> to do without it, using the GNU date command instead...


That's so awesome! I wanna have sex with you right now.
 
Reply With Quote
 
Arved Sandstrom
Guest
Posts: n/a
 
      06-07-2011
On 11-06-07 09:51 AM, bugbear wrote:
> Silvio wrote:
>> On 06/07/2011 01:59 PM, Lawrence D'Oliveiro wrote:
>>> The following one-liner sets the versionName attribute in
>>> AndroidManifest.xml to a number based on the number of days (accurate to
>>> 0.1 day) since the *nix epoch. This is what I’ve been using for a
>>> version number in one or two projects, in lieu of anything that makes
>>> more sense.
>>>
>>> sed -i -r 's/(android:versionName=\")[^\"]*(\")/\1'"$(bc<<<"scale = 1;
>>> ($(Julian -f) - $(Julian -d 1970 1 1)) / 1")"'\2/' AndroidManifest.xml
>>>
>>> This needs my “Julian” script, available here
>>> <https://github.com/ldo/Julian>. Though it can probably be rewritten
>>> to do without it, using the GNU “date” command instead...

>>
>> What about date +%s%N

>
> I am reminded of this:
>
> http://www.infiltec.com/j-h-wrld.htm
>
> BugBear


I caught myself doing something like this last week. I had what seemed
like a rather thorny problem with very dynamic objects for backing up
C#.NET WPF property grids, and temporarily ended up down the
Reflection.Emit and IDynamicMetaObjectProvider trails (*). A body can
definitely end up not seeing the forest for the trees when doing this
kind of thing, and at one point I ended up with

value = Activator.CreateInstance(typeof(dataType), "");

to get an empty string, when I in fact knew by virtue of having arrived
at that particular switch case that I needed an empty string...otherwise
I wouldn't have been calling the constructor form that accepted a string
parameter. IOW, the switch case for the above was for strings only, and
I knew that 'dataType' had to be a string value.

It struck me all of a sudden, and I ended up with

value = "";

Rule of Thumb: if things have gotten bloody complicated and they don't
feel like they ought to have been that way, you're probably right.

AHS

* I eventually realized that simple dynamic objects did handle the problem.
 
Reply With Quote
 
Lawrence D'Oliveiro
Guest
Posts: n/a
 
      06-07-2011
In message <4dee15eb$0$49174$>, Silvio wrote:

> What about date +%s%N


Close. Try this version: doesn’t need Julian, and also shorter:

sed -i -r 's/(android:versionName=\")[^\"]*(\")/\1'"$(bc <<<"scale = 1; ($(date +%s)) / 86400")"'\2/' AndroidManifest.xml


 
Reply With Quote
 
Andreas Leitgeb
Guest
Posts: n/a
 
      06-07-2011
Lawrence D'Oliveiro <_zealand> wrote:
> In message <4dee15eb$0$49174$>, Silvio wrote:
>> What about date +%s%N

> Close. Try this version: doesn’t need Julian, and also shorter:
> sed -i -r 's/(android:versionName=\")[^\"]*(\")/\1'"$(bc <<<"scale = 1; ($(date +%s)) / 86400")"'\2/' AndroidManifest.xml


I don't quite see the reason why you would actually capture the closing
double-quote char... and double-quotes aren't special to "sed -r", so they
need no backslash before them. Then the last lingle-quoted part can be
included into the double-quoted middle part, re-introducing one \", but
making it again shorter. Also, removing some redundant spaces, quotes and
parens from around bc, and replacing one of the $(...) with backticks
shortens it again.

sed -i -r 's/(android:versionName=")[^"]*"/\1'$(bc<<<scale=1\;`date +%s`/86400)\"/ AndroidManifest.xml

Btw., it won't be compatible with older shells (e.g. ksh), though,
for the "<<<".
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Where to get stand alone Dot Net Framework version 1.1, version2.0, version 3.0, version 3.5, version 2.0 SP1, version 3.0 SP1 ? MowGreen [MVP] ASP .Net 5 02-09-2008 01:55 AM
Re: Where to get stand alone Dot Net Framework version 1.1, version 2.0, version 3.0, version 3.5, version 2.0 SP1, version 3.0 SP1 ? PA Bear [MS MVP] ASP .Net 0 02-05-2008 03:28 AM
Re: Where to get stand alone Dot Net Framework version 1.1, version 2.0, version 3.0, version 3.5, version 2.0 SP1, version 3.0 SP1 ? V Green ASP .Net 0 02-05-2008 02:45 AM
numbering plan on Cisco 2600 GW Tony Cisco 0 11-19-2004 06:36 AM
numbering rows in datagrid buran ASP .Net 2 07-07-2003 12:48 PM



Advertisments