text:
Q: Display a time using a given timezone in Django I'm developing a Django app for logging dives and each dive has a datetime and a timezone in it. I'm using the django-timezone-field app for the timezone.
class Dive(models.Model):
  ...
  date_time_in = models.DateTimeField(default=timezone.now)
  timezone = TimeZoneField(default=timezone.get_current_timezone_name())

So the user is able to enter a datetime string ("2016-07-11 14:00") and select a timezone ("Asia/Bangkok" - UTC+0700), I then set the timezone of the datetime to the one given in my view like this:
def log_dive(request):
  if request.method == 'POST':
    form = DiveForm(request.POST)
    if form.is_valid():
      dive = form.save(commit=False)
      date = dive.date_time_in
      date = date.replace(tzinfo=None)
      dive.date_time_in = dive.timezone.localize(date)
      dive.save()

The database then stores the datetime as UTC in the database (SELECT statement gives it in my local timezone):
# SELECT date_time_in, timezone FROM divelog_dive ORDER BY number DESC;
      date_time_in      |     timezone
------------------------+------------------
 2014-07-11 17:00:00+10 | Asia/Bangkok

Now there are two things I'm struggling with:
1) I want to display the dates in the given timezone, however I can't seem to stop it defaulting to the TIME_ZONE setting.
2) If the user edits the record, the time displayed in the edit field should be the one they originally entered (14:00), instead it's showing it in the current timezone (17:00).

A: Check your timezone setting in settings.py

A: Do you have USE_TZ = true in your settings file? If you created your app using the djangoadmin-startproject command, it is set by default.
Also, I struggled with timezones at my last job but found that using pytz really helped. Have you tried that package yet?
EDIT: Ok man I may be way off, but since noone else has answered and I feel the timezone struggle, here is something I noticed...
You are replacing the date object with tz_info=None, but wouldn't you want to instead replace that with the timezone from the database? So you would get that timezone and do a replace using the valid format (tzinfo=blah...)?
Like I said I may be way off but if that helps there you go.

A: Sorry, I don't think I explained my problem very well. I finally figured this out, so I'll answer my own question.
1) turned out to be easy, Django have a template tag for displaying times in a given zone:
{{ dive.date_time_in|timezone:dive.timezone|date:"Y-m-d H:i e" }}

For 2), I came across [1] which lead me to this solution: In the view, after getting the object from the database, I use astimezone(...) to convert the date value (which the DB stores as UTC) into the given timezone. I then use replace(tzinfo=None) to make it naive and then it displays correctly on my form.
def edit_dive(request, dive_id=None):
  dive = None
  if dive_id != None:
    dive = get_object_or_404(Dive, pk=dive_id)
    local_date = dive.date_time_in.astimezone(timezone(str(dive.timezone)))
    dive.date_time_in = local_date.replace(tzinfo=None)

[1] http://www.saltycrane.com/blog/2009/05/converting-time-zones-datetime-objects-python/


Just a quick instruction to how to compile teeworlds 0.7 on windows with Visual Studio since there are some changes since 0.6.
I will not explain what you need for compiling at all, things like Visual Studio and python etc. should be clear. This guide is for those who already know how to compile 0.6. In short, it's all about downloading SDL and Freetype.
1) Download and extract the teeworlds source. Download and extract and compile bam.
In order to compile teeworlds, we will now need SDL and Freetype.
2) Download and extract SDL. You will find an "include" and "lib" folder there. Copy them into your teeworlds source folder at \teeworldsSource\other\sdl.
3) Now go to \teeworldsSource\other\sdl\lib\win32\ and copy "SDL2.lib" and "SDL2main.lib" into the root direction of your teeworlds folder (\teeworldsSource\).
4) Download and extract Freetype. Also here you will find an "include" and "win32" / "win64" folder. Copy them into your teeworlds source at \teeworldsSource\other\freetype.
5) Now go to \teeworldsSource\other\freetype\win32\ and copy "freetype.lib" into the root direction of your teeworlds folder (\teeworldsSource\).
Now we are ready to compile, although we are not finish.
6) First, the commands in bam.lua have changed. Available are "game", "client", "server", "content". Default is "game" and means server, client and content.
Compile what you want but at first I recommend to do "game" because this will create client, server and - most important - your "/data/" folder (but you can also create the data folder with "content").
7) Second, the place where the finish stuff comes out has changed. It's not the root direction like in 0.6 anymore, you will now find it at \teeworldsSource\build\x86.
8) To start your compiled client or server, you need SDL2.dll and freetype.dll. Copy them from \teeworldsSource\other\sdl\lib\win32 and \teeworldsSource\other\freetype\win32 into \teeworldsSource\build\x86.
Finish! Now you should be able to compile and start teeworlds.
The most annoying thing is to copy SDL and freetype into the right folders, but with the links above and this instruction I hope it's more easy for you.
why dont they include it in source anymore?
2) Download and extract SDL. You will find an "include" and "lib" folder there. Copy them into your teeworlds source folder at \teeworldsSource\other\sdl. and in "lib" rename the folders "win32" to "x86" and "win64" to "x64"
5) Now go to \teeworldsSource\other\freetype\ and copy "win32" / "win64" to a new folder named "lib" and rename the folders "win32" to "x86" and "win64" to "x64"
Of course this looks better at the end, but I think rename the downloaded stuff could lead to confusion later. Note that there are different versions of SDL and freetype for Windows, one for Visual Studio and one for mingw. And then there is Linux.
How does one actually compile 0.7 on windows? Are the binaries coming out soon?
Can someone help me compile from source? I am getting the following error when I try to compile with ..\bam\bam.
It has something to do with freetype but I don't know what to do. I made sure to download freetype from the link above, copy "include" and "win32" into \teeworldsSource\other\freetype, and moved (cut paist) "freetype.lib" into the teeworlds root directory like it says.
just copy those files(dll and libs) to right path.
Because unfortunately, MinGW and Visual Studio differ much. The folders are different and the files you need.. So the files from the links in my post are the wrong if you want to compile with MinGW, they should not work. Just google for freetype & sdl2 for MinGW (64bit or 32bit, this is important!), they are easy to find. I will add them when I have time!
Sorry yes I got it working.


The island of Malta covers just 316 sq km in land area. Once the immigrants have arrived at the island, they are arrested for illegal migrants and then transferred to closed detention centres where they may remain for up to 18 months. During that period of time the Maltese authorities carry out the same interrogations over and over again to come to know the country of origin of the immigrants.


There is SO much beauty to bringing a new life into the world. It isn't just about the pregnancy, but about everything that the pregnancy stands for. All of the moments leading up to it (meeting, falling in love, and whatever other story it is that led to this moment), and more importantly, the moments after.
I think there is something so peaceful and elegant about maternity photos. And when you incorporate boudoir into them, it's an opportunity for the mom to really see herself the way she deserves to see herself. It's easy to get lost in the numbers on the scale. It's easy to see the body transformations and to be terrified of it. But it's beyond important to remember that what you are doing is INCREDIBLE. Your body is quite literally creating new life. A new child that you will have love for like you never knew was possible. Stretch marks may come, loose skin may stick around. You may struggle with your physical appearance from time to time. But take a moment to revel in the sheer beauty of what you are doing, and of how you actually look to others around you.
Momma. You-are-amazing. And don't you forget it!


Experienced actor and producer having graduated from the University of Glamorgan in 2008 with a First degree in Drama.
Short film funded by Ffilm Cymru/BFI.NETWORK; "Louder is Not Always Clearer" with Jonny Cotsen. Producer with Fio.
We're on the lookout for street performers within a travel-able distance to Pontypridd, so we can create a database of performers for future events.
Fio are looking for actors, with a background in devising, to work on an R&D project in February, investigating immigration and the refugee crisis.
The audition and R&D week will be based in Cardiff, with the audition taking place on Monday 13th February. No travel expenses will be offered for either the audition or the R&D week.
Hi Alan I can't seem to open the link to your short film casting. Can I get details elsewhere on the site?
I tried sending my details via that e mail address for that Short Film casting but for some reason it's failing. Would you mind if I sent them to you?
Yes please... I'm certainly up for coming along!
Yep, just a case of turning up really. We'll give you some scripts there to work on, and then we'll do the audition as everyone feels ready.


text:
<?xml version="1.0"?>
<ruleset name="PSR2Modified">
    <rule ref="PSR2">
        <exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps" />
        <exclude name="PSR2.ControlStructures.ControlStructureSpacing.SpacingAfterOpenBrace" />
        <exclude name="Squiz.ControlStructures.ForEachLoopDeclaration.SpaceAfterOpen" />
        <exclude name="Squiz.Functions.MultiLineFunctionDeclaration.BraceOnSameLine" />
        <exclude name="Squiz.Functions.MultiLineFunctionDeclaration.UseOneParamPerLine" />
    </rule>

    <!-- Disable "No PHP code was found in this file" for symlinks. -->
    <rule ref="Internal.NoCodeFound">
        <severity>0</severity>
    </rule>
</ruleset>

redpajama_set_name: RedPajamaGithub


text:
Q: If multiple edit buttons is having same HTML coding how will I click the button in Selenium I'm new to Selenium. Below is code:
<i _ngcontent-c13="" aria-hidden="true" class="fa fa-edit" style="color: green;cursor: pointer;"></i>

I have all edit buttons with the same type. How do I click on each of the buttons? Can anyone help me with the XPath?

A: EASY
Right click on element in browser > inspect > right click on the highlighted code > copy > copy xpath. Now we have the xpath so:
driver.findElement(By.xpath("paste_xpath")).some_action();

Let me know if this works, there are more other options to discuss + add the code block that contains all the buttons.
HARD
First we need to get the xpath, you can build it based on the formula:
Xpath=//tagname[@attribute='value']

Where:

*

*// : Select current node.

*Tagname: Tagname of the particular node.

*@:Select attribute. Attribute: Attribute name of the node.

*Value: Value of the attribute.

More details you can find HERE
Thanks,

redpajama_set_name: RedPajamaStackExchange